Answers for "create a button android studio"

3

android studio button usage

//this for xml file 
<Button  
        android:id="@+id/button"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_centerHorizontal="true"  
        android:layout_marginTop="109dp"  
        android:text="hello"  
 /> 

//this for java file 
Button btn;
  @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
  btn = (Button) findViewById(R.id.button);
        btn.setOnClickListener(new View.OnClickListener() {  
            @Override  
            public void onClick(View view) {  
               //do something
            }  
        }); 
    }
Posted by: Guest on December-06-2020
0

android java buttons

public void clickFunction(View view)
/* Text attributes + onClick (in this case: clickFunction)
Basics: Constraint list / layout margin */
Posted by: Guest on January-05-2021

Code answers related to "create a button android studio"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language