Home > Back-end >  For the answer! AndroidStudio Settings button listener not running after, page ever for a moment
For the answer! AndroidStudio Settings button listener not running after, page ever for a moment

Time:09-27

Set before the listener can also run button didn't, won't appear after the set up, also do not complain,
This is the code for the XML file
<? The XML version="1.0" encoding="utf-8"?>
XMLNS: tools="http://schemas.android.com/tools"
The android: id="@ + id/activity_main"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: orientation="vertical"
Tools: context="MainActivity" & gt;
Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: layout_margin="20 dp"
The android: orientation="horizontal" & gt;
Android: layout_width="match_parent"
Android: layout_height="wrap_content"
Android: text="jump welcome"
Android: layout_weight="1"
Android: padding="10 dp"
The android: id="@ + id/b1/& gt;



Java code
Package com. Example. Myapplication;

import androidx.appcompat.app.AppCompatActivity;

The import android. Content. Intent;
The import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

Public class MainActivity extends AppCompatActivity {

The Button for the=(Button) the findViewById (R.i db 1);

@ Override
Protected void onCreate (final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

For the setOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
Intent Intent=new Intent (MainActivity. This text. The class).
startActivity(intent);
}
});

}
}

CodePudding user response:

The Button for the=(Button) the findViewById (R.i db 1); Written on the setContentView loading activity_main first below is for you
  • Related