İki Activity Kullanımı

kingfishblacksmithΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

387 εμφανίσεις

İki Activity Kullanımı



package com.ilker;


import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;


public class DenemeActivity extends Activity {


/** Called when the activity is first created.

*/


@Override


public void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.main);


}




public void Altgit(final View view){



startActivity(new Intent(this,altekran.class
));


}

}



package com.ilker;


import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;


public class altekran extends Activity {


/** Called when the activity is first created. */


@Override


public void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.altekran);


}




public void Anagit(final View view){



startActivity(new Intent(this,DenemeActivity.class));


}

}



<?
xml

version
=
"1.0"

encoding
=
"utf
-
8"
?>

<
manifest

xmlns:android
=
"http://schemas.android.com/apk/res/android"


package
=
"com.ilker"


android:versionCode
=
"1"


android:versionName
=
"1.0"

>



<
uses
-
sdk

android:minSdkVersion
=
"8"

/>



<
application


android:icon
=
"@drawable/ic_launcher"


android:label
=
"@string/app_name"

>


<
activity


android:name
=
".DenemeActivity"


android:label
=
"@string/app_name"

>


<
intent
-
filter
>


<
action

android:name
=
"android.intent.action.MAIN"

/>



<
category

android:name
=
"android.intent.category.LAUNCHER"

/>


</
intent
-
filter
>


</
activity
>


<
activity

android:name
=
".altekran"
></
activity
>


</
application
>


</
manifest
>











































Buton

Kullanımı


package com.deneme;


import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.widget.EditText;


public class DenemebutonActivity extends Activity {


private EditText text;


/** Called when the activity is first created. */


@Override


public void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.main);




text = (EditText) fin
dViewById(R.id.editText1);


text.setText("
Butona Basılmadı
");


}


public void myClickHandler(View view) {



switch (view.getId()) {



case R.id.button1:



text.setText("Button 1
e basıldı
");



break;



case R.id.button2:



text.setText("Button 2
ye basıldı
");



break;



case R.id.button3:



text.setText("Button 3
e basıldı
");



break;



}



}

}


<?
xml

version
=
"1.0"

encoding
=
"utf
-
8"
?>

<
LinearLayout

xmlns:android
=
"http://schemas.android.com/apk/res/android"



android:layout_width
=
"fill_parent"


android:layout_height
=
"fill_parent"


android:orientation
=
"vertical"

>



<
TextView


android:layout_width
=
"fill_parent"


android:layout_height
=
"wrap_content"


android:text
=
"@string/hello"

/
>



<
EditText


android:id
=
"@+id/editText1"


android:layout_width
=
"286dp"


android:layout_height
=
"wrap_content"

>



<
requestFocus

/>


</
EditText
>



<
Button


android:id
=
"@+id/button1"


android:layout_width
=
"
wrap_content"


android:layout_height
=
"wrap_content"


android:onClick
=
"myClickHandler"


android:text
=
"Button"

/>



<
Button


android:id
=
"@+id/button2"


android:layout_width
=
"wrap_content"


android:layout_height
=
"w
rap_content"


android:onClick
=
"myClickHandler"


android:text
=
"Button"

/>



<
Button


android:id
=
"@+id/button3"


android:layout_width
=
"wrap_content"


android:layout_height
=
"wrap_content"


android:onClick
=
"
myClickHandler"


android:text
=
"Button"

/>


</
LinearLayout
>






































3. Örnek


package

ilker.deneme;


import

android.app.Activity;

import

android.os.Bundle;

import

android.widget.Button;

import

android.widget.Toast;

import

android.view.View;

import

android.view.View.OnClickListener
;


public

class

DenemeActivity
extends

Activity {


/** Called when the activity is first created. */


@Override


public

void

onCreate(Bundle savedInstanceState) {


super
.onCreate(
savedInstanceState);


setContentView(R.layout.
main
);



Button buton=(Button) findViewById(R.id.
button1
);


buton.setOnClickListener(
new

OnClicklListener(){




public

void

onClick(View v){




Toast.
makeText
(DenemeActivity.
this
,
"
Deneme Yazısı
"
,
Toast.
LENGTH_LONG
).show();



}


});






}

}



<?
xml

version
=
"1.0"

encoding
=
"utf
-
8"
?>

<
LinearLayout

xmlns:android
=
"http://schemas.android.com/apk/res/android"


android:layout_width
=
"fill_parent"


android:layout_height
=
"fill_parent"


android:orientation
=
"vertical"

>



<
Button


android:id
=
"@+id/button1"


android:layout_width
=
"wrap_content"


android:layout_height
=
"wrap_content"


android:text
=
"Button"

/>


</
LinearLayout
>