Taner Şenyurt

Kişisel gelişim sitesi…

Google Android

March5

Lets develop mobile applications with using google android SDK.

Firstly we have to download Eclipse (at least i download it :-P ).From Eclipse.Org

after that extract it some where and open Eclipse 3.4 Ganymede

  1. Start Eclipse, then select Help > Software Updates….
  2. In the dialog that appears, click the Available Software tab.
  3. Click Add Site…
  4. Enter this as the Location:
    https://dl-ssl.google.com/android/eclipse/
    Alternatively, you can use http in the Location URL, if you are having trouble with https (https is preferred for security reasons).
    http://dl-ssl.google.com/android/eclipse/
    Click OK.
  5. Back in the Available Software view, you should see the plugin. Select the checkbox next to Developer Tools and click Install…
  6. On the subsequent Install window, “Android Developer Tools”, and “Android Editors” should both be checked. The Android Editors feature is optional, but recommended. If you choose to install it, you need the WST plugin mentioned earlier in this page. Click Next.
  7. Accept the license agreement and click Finish.
  8. Restart Eclipse.

After all these operations lets add our SDK.Download sdk from here

Extract your sdk somewhere and add your sdk’s path with clicking Window->Preferences-Android

then with using browse select your sdk location. That’s it.Lets watch how its simple to write code for mobile phones.

main.xml :

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5. android:orientation="vertical"
  6.  
  7. android:layout_width="fill_parent"
  8.  
  9. android:layout_height="fill_parent"
  10.  
  11. >
  12.  
  13. <TextView
  14.  
  15. android:layout_width="fill_parent"
  16.  
  17. android:layout_height="wrap_content"
  18.  
  19. android:text="@string/hello"
  20.  
  21. />
  22.  
  23. <EditText android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
  24.  
  25. <EditText android:id="@+id/EditText02" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
  26.  
  27. <CheckBox android:id="@+id/CheckBox01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Copy From Down"></CheckBox>
  28.  
  29. <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Make it simpler"></Button>
  30.  
  31. </LinearLayout>

HelloAndroid.Java :

  1. package com.Turshu.Android.Hello;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.widget.Button;
  8. import android.widget.CheckBox;
  9. import android.widget.EditText;
  10.  
  11. public class HelloAndroid extends Activity {
  12. /** Called when the activity is first created. */
  13. private EditText txt1;
  14. private EditText txt2;
  15. private CheckBox chk;
  16. private Button btn;
  17.  
  18. @Override
  19. public void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21. setContentView(R.layout.main);
  22.  
  23. txt1=(EditText)findViewById(R.id.EditText01);
  24. txt2=(EditText)findViewById(R.id.EditText02);
  25. chk=(CheckBox)findViewById(R.id.CheckBox01);
  26. btn=(Button)findViewById(R.id.Button01);
  27.  
  28. btn.setOnClickListener(listen_btn);
  29.  
  30. }
  31.  
  32. private OnClickListener listen_btn=new  OnClickListener() {
  33.  
  34. @Override
  35. public void onClick(View v) {
  36. // TODO Auto-generated method stub
  37. if(chk.isChecked()==true)
  38. {
  39. txt1.setText(txt2.getText());
  40. }else {
  41. txt2.setText(txt1.getText());
  42. }
  43. }
  44.  
  45. };
  46. }


posted under Java, Programming

Comments are closed.