सबसे पहले आप एक के लिए यूआई बनाने की जरूरत लेआउट intro_activity_1.XML फ़ाइल का उपयोग करके बटन। बाद एंड्रॉयड बटन का उपयोग करके समूह के लिए है कि सेट आईडी: आईडी = "@ + id/बटन"
उदाहरण:
intro_activity_1.xml
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:text="NEXT" />
अब पहली गतिविधि के अपने जावा वर्ग बदल जाते हैं। इस उदाहरण में, हम IntroActivity1 की जावा फ़ाइल बदलते हैं।जावा
उदाहरण:
IntroActivity1.java
//header, import and package data
public class IntroActivity1 extends AppCompatActivity {
Button next_btn;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intro_activity_1);
next_btn=(Button)findViewById(R.id.button);//button class
next_btn.setOnClickListener(new View.OnClickListener(){
public void onClick(View arg0){
//Start new activity class
Intent myIntent=new Intent(IntroActivity1.this,IntroActivity2.class);
startActivity(myIntent);
}
});
}
गतिविधि परिवर्तक यात्रा के बारे में अधिक जानकारी के लिए: https://answerdone.blogspot.com/2018/01/how-to-change-new-activity-in-android.html
स्रोत
2018-01-14 11:07:51
"क्रियाएँ", नहीं "गतिविधि के"। कृप्या। –