D:\chandreadymadeshop\app\src\main\res\layout\activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/chandra">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TextView
android:id="@+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Whatever you Want !!"
android:textColor="@android:color/holo_red_dark"
android:textSize="40sp" /> <CheckBox
android:id="@+id/CB1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Silk Saree"
android:textColor="@android:color/holo_orange_dark" /> <CheckBox
android:id="@+id/CB2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Synthetic Saree"
android:textColor="@android:color/holo_green_dark" /> <CheckBox
android:id="@+id/CB3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Cotton Saree"
android:textColor="@android:color/holo_blue_dark" />
<CheckBox
android:id="@+id/CB4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Jute Saree"
android:textColor="@android:color/holo_red_light" />
<Button
android:layout_width="314dp"
android:layout_height="wrap_content"
android:text="PRESS IT"
android:id="@+id/btn"
android:background="#f8f40b"
android:textColor="#fd0707"/> </LinearLayout> </ScrollView>
-----------------------------------------------------------------------------------------
D:\chandreadymadeshop\app\src\main\java\com\ldc\chandreadymadeshop\MainActivity.java
package com.ldc.chandreadymadeshop; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.Toast; public class MainActivity extends Activity { Button btn; CheckBox cb1, cb2, cb3,cb4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cb1=(CheckBox) findViewById(R.id.CB1); cb2=(CheckBox) findViewById(R.id.CB2); cb3=(CheckBox) findViewById(R.id.CB3); cb4=(CheckBox) findViewById(R.id.CB4); btn=(Button) findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(cb1.isChecked() == true && cb2.isChecked()== false && cb3.isChecked()==false && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"Silk Saree", Toast.LENGTH_LONG).show(); if(cb1.isChecked() == false && cb2.isChecked()==true && cb3.isChecked()==false && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"Synthetic Saree",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()==true && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"Cotton Saree",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()== false && cb4.isChecked()==true) Toast.makeText(getBaseContext(),"Jute Saree ",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== false && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree ",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== true && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree and Synthetic Saree ",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == true && cb2.isChecked()==true && cb3.isChecked()== true && cb4.isChecked()==true) Toast.makeText(getBaseContext(),"Silk Sree Cotton Saree , Synthetic Saree and Jute Saree",Toast.LENGTH_LONG).show(); if(cb1.isChecked() == false && cb2.isChecked()==false && cb3.isChecked()==false && cb4.isChecked()==false) Toast.makeText(getBaseContext(),"OOPS! you haven`t selected anythng (: (: ",Toast.LENGTH_LONG).show(); } }); } }
------------------------------------------------------------------------------------
No comments:
Post a Comment