Tuesday, 20 February 2018

Android From Fitst Screen To Second Screen Activity

အ​ေပၚမွာ ​ေျပာထားတဲ့အတိုင္​း AIDE Apk စတင္​ဖြင္​့ပါ။ၿပီးရင္​ res>>>>layout>>>>main.xmlကိုဖြင္​့ပါ။
​ေအာက္​က code ကို ထည္​့ပါ။
<Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Click me to another screen" />
main2.xml ဆိုၿပီး ဖိုင္အသစ္​ ဖြင္​့​ေပးရမယ္​။
​ေအာက္​တြင္​ ၾကည္​့ရန္

TextView
android:layout_height="wrap_content"
android:text="AIDE"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"/>
Add new xml file here ကိုႏိွပ္​ပါ။
src >>> MainActivity.java ကိုဖြင္​့ပါ။ ​ေအာက္​က code ကို ထည္​့ပါ။
import(အပိုင္​း)
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
Button button;
Source(အပုိင္​း)
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, MainActivity2.class);
                startActivity(intent);   }});
MainActivity2.java ဖိုင္​အသစ္​ဖြင္​့မည္​။
​ေအာက္​တြင္ ၾကည္​့ရန္​
Add new Class here ကိုႏိွပ္​ပါ။
MainActivity2.java တြင္​ ​ေအာက္​က Code ထည္​့ရန္​
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity2 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
}
}
AndroidManifest.xml(အပိုင္​း)
  <activity
            android:label="@string/app_name"
            android:name=".App2Activity" >
        </activity>
အဆင္​​ေျပပါ​ေစ။
​ေရးသားသူ =​ေဇယ်ာလင္​း

​ေရးသားသူ =​ေဇယ်ာလင္​း

No comments: