ad728

Thursday, December 15, 2016

AIDE Tutorial - 17 Check Box

AIDE Tutorial - 17 Check Box

Watch the video below and try yourself
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:onClick="aaa"
android:id="@+id/one"
android:text="Phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<CheckBox
android:onClick="bbb"
android:id="@+id/two"
android:text="SD Card"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Java
package com.mycompany.myapp3;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
public class MainActivity extends Activity
{@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
public void aaa(View view){
CheckBox one =(CheckBox)findViewById(R.id.one);
if (one.isChecked()){
Toast.makeText(this,"Phone is selected",
Toast.LENGTH_SHORT).show();}
else{Toast.makeText(this, "Phone is not selected",
Toast.LENGTH_SHORT).show();}}
public void bbb(View view){
CheckBox two=(CheckBox)findViewById(R.id.two);
if (two.isChecked()){
Toast.makeText(this,"SD Card is selected",
Toast.LENGTH_SHORT).show();}
else{Toast.makeText(this, "SD Card is not selected",
Toast.LENGTH_SHORT).show();}}}
Share:

0 comments:

Post a Comment

Total Pageviews

Sponsor

Sponsor

ad300