Open top menu

Android Custom Login Screen Design  ?

try this design....

In this design used EditText without Border line...


without_borderline.xml.
..................................................................................................................................................................
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">

 <item android:state_focused="true" >
    <shape android:shape="line">
        <gradient
            android:startColor="#8e44ad"
            android:endColor="#8e44ad"
            android:angle="270" />
        <stroke
            android:width="3dp"
            android:color="#F8B334" />
         
    </shape>
</item>  
</selector>


main.xml.
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#8e44ad"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="131dp"
        android:src="@drawable/user_male_circle" />

    <EditText
        android:id="@+id/editText_email"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="54dp"
        android:background="@drawable/without_borderline"
        android:ems="10"
        android:gravity="center"
        android:hint="Email Address"
        android:inputType="textEmailAddress"
        android:padding="8dp"
        android:textColorHint="#ffffff" />

    <EditText
        android:id="@+id/editText_password"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText_email"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="14dp"
        android:background="@drawable/without_borderline"
        android:ems="10"
        android:gravity="center"
        android:hint="*******"
        android:inputType="textPassword"
        android:padding="8dp"
        android:textColorHint="#ffffff" >
    </EditText>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="52dp"
        android:text="UserLogin"
        android:textSize="18sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/editText_password"
        android:layout_marginRight="24dp"
        android:layout_marginTop="24dp"
        android:text="New User Account"
        android:textStyle="bold|italic" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_below="@+id/editText_email"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="#ffffff" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_below="@+id/editText_password"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="#ffffff" />

</RelativeLayout>

...................................................................................................................................................................

user icon image download here....

Read more

Android Custom  ProgrssBar with Animation ?

In blog explain how to create Ring ProgressBar in android ....try this

Step 1 Create anim class inside res/drawable/ring_progress_anim...

ring_progress_anim.xml
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >
    <shape
        android:innerRadius="60dp"
        android:shape="ring"
        android:thickness="8dp"
        android:useLevel="false" >
        <size
            android:height="80dp"
            android:width="80dp" />
        <gradient
            android:centerColor="#1e6008"
            android:centerY="0.5"
            android:endColor="#afab24"
            android:startColor="#0d4599"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

Step 2.Create activity_main.xml class inside res/layout/ folder..

activity_main.xml.
...................................................................................................................................................................

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/logoweb" />

   <ProgressBar
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:layout_gravity="center"
   android:layout_marginTop="60dp"
   android:indeterminateDrawable="@drawable/ring_progress_anim" />

</LinearLayout>









Link Learn More...
Read more

Android Custom Circle  Shape ProgrssBar with Animation ?

In blog explain how to create Circle ProgressBar in android ....try this

Step 1 Create anim class inside res/drawable/circle_progress_anim...

circle_progress_anim.xml
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >
    <shape
        android:innerRadius="60dp"
        android:shape="oval"
        android:thickness="4dp"
        android:useLevel="false" >
        <size
            android:height="80dp"
            android:width="80dp" />
        <gradient
            android:centerColor="#1e6008"
            android:centerY="0.5"
            android:endColor="#afab24"
            android:startColor="#0d4599"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

Step 2.Create activity_main.xml class inside res/layout/ folder..

activity_main.xml.
...................................................................................................................................................................

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/logoweb" />

   <ProgressBar
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:layout_gravity="center"
   android:layout_marginTop="60dp"
   android:indeterminateDrawable="@drawable/circle
_progress_anim" />

</LinearLayout>










 Learn More...
Read more

Android Custom Rectangle Shape ProgrssBar with Animation ?

In blog explain how to create Rectangle ProgressBar in android ....try this

Step 1 Create anim class inside res/drawable/rotate_progress_anim...

rotate_progress_anim.xml
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >
    <shape
        android:innerRadius="60dp"
        android:shape="rectangle"
        android:thickness="4dp"
        android:useLevel="false" >
        <size
            android:height="80dp"
            android:width="80dp" />
        <gradient
            android:centerColor="#1e6008"
            android:centerY="0.5"
            android:endColor="#afab24"
            android:startColor="#0d4599"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

Step 2.Create activity_main.xml class inside res/layout/ folder..

activity_main.xml.
...................................................................................................................................................................

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/logoweb" />

   <ProgressBar
   android:layout_width="200dp"
   android:layout_height="200dp"
   android:layout_gravity="center"
   android:layout_marginTop="60dp"
   android:indeterminateDrawable="@drawable/rotate_progress_anim" />

</LinearLayout>



Step 3. Create MainActivity.java class inside src folder...
Main_Activity.java.
...................................................................................................................................................................

package com.androidbeginner.testcode;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;

@SuppressLint("ResourceAsColor")
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setTitle("Rectangle Shape ProgressBar");
setContentView(R.layout.activity_main);
 
}

}



Read more

How to display Justify text in android ?

In this blog explain how to justify text in android show below code
the blog used align & justify text in about us in android app .

Step 1 You can create activity_main.xml class inside res folder...

activity_main.xml. 

In this class create webview .
...................................................................................................................................................................

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/logoweb" />

    <WebView
        android:id="@+id/web_history"
        android:layout_width="215dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        android:background="#cfcfcf"
        android:paddingBottom="5dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:src="@drawable/logoweb" />

</LinearLayout>




Step 2. you can add html tag in string class inside res/string....
String.xml
..................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Test Code</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
  
    <string name="Yellow">Yellow</string><string name="History">
<![CDATA[
<html>
 <head></head>
 <body style="text-align:justify;color:white;background-color:green;">
 Mohandas Karamchand Gandhi, more commonly known as ‘Mahatma’ (meaning ‘Great Soul’) was born in Porbandar, Gujarat, in North West India, on 2nd October 1869, into a Hindu Modh family. His father was the Chief Minister of Porbandar, and his mother’s religious devotion meant that his upbringing was infused with the Jain pacifist teachings of mutual tolerance, non-injury to living beings and vegetarianism
 </body>
</html>
]]>
    </string

</resources>


Setp 3. create MainActivity.java class inside src folder...


MainActivity.java

In this class load html text in webview from String class.
...................................................................................................................................................................

 package com.androidbeginner.testcode;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.webkit.WebView;

@SuppressLint("ResourceAsColor")
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setTitle("Justify text ");
setContentView(R.layout.activity_main);
WebView view = (WebView) findViewById(R.id.web_history);
view.getSettings();
view.setBackgroundColor(Color.GREEN);
view.loadData(getString(R.string.History), "text/html", "utf-8");
}

}




Read more

Android-Loading HTML Directly into WebView ?

Its  a possible HTML Code run directly on WebView without load URL.


<WebView
        android:id="@+id/WebView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>




 MainActivity.java
...................................................................................................................................................................

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebView;

public class InfoActivity extends Activity
{
    @SuppressLint("NewApi")
@Override
    protected void onCreate(Bundle savedInstanceState)
    {
       
       super.onCreate(savedInstanceState);
getActionBar().setTitle("About");
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);

setContentView(R.layout.info_activity);

           
WebView webView = (WebView) findViewById(R.id.WebView);

               
String html = "<html><body>Hello, World!</body></html>";
String mime = "text/html";
String encoding = "utf-8";

webView.getSettings().setJavaScriptEnabled(true);
              // load html tag
webView.loadDataWithBaseURL(null, html, mime, encoding, null);

   
               
    }
   
   
    @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:

finish();

return true;
default:
return super.onOptionsItemSelected(item);
}
}

@Override
public void onBackPressed() {

super.onBackPressed();
finish();

}

}

Read more

How to Export Android App Step By Step In Eclipse

In this blog ,explain how to export android in eclipse platform. 

Step 1. Open the eclipse and choose  project in eclipse .

Step 2. Right click on export project & select the Android Tool --> Export Signed Application Package.show below image(1.0).



1.0

Step 3.Then, Open Export Signed Application Package Window ,Choose android project.show below image(1.1)



1.1
Step 4.Then, onClick Next button open new window choose the one option keystore selection .
first,Use Existing Keystore.(when you can created keystore already.)
second, Use Create New Keystore.(when you can create a new keystore).
After ketstore selection enter the password and confirm password, and click on next button.show below image(1.2).



1.2

Step 5.Then ,Open the new key Creation window ,you can fill all text field .show below image (1.3).


1.3


Step 6.Then, Onclick next button ,Open new Destination and key / certificate check.show image(1.4).


1.4




Step 5. onclick finish Button. you can check keystore destination show export android app apk file.


thank you for watching this blog.


Read more

How to Implement selector ImageButton In android?


In this blog explain how to implemet selector ImageButton in android. you can change easily image background color onclick imageButton via selector xml class. try this code

Stepe 1. first ,you can create Button selector xml class inside res/drawable folder...

button_selector.xml
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_pressed_yellow"
          android:state_pressed="true" />
    <item android:drawable="@drawable/button_focused_orange"
          android:state_focused="true" />
    <item android:drawable="@drawable/button_normal_green" />
</selector>




Stepe 2 . create activity_main.xml class inside the res/layout folder...

activity_main.xml .
.................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Androidbeginner point" 
        android:textSize="25dp"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"/>

    <Button
        android:id="@+id/ButtonSelector"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_selector"
        android:layout_marginTop="30dp" 
        android:layout_gravity="center"/>
    
</LinearLayout>


Stepe 3.create main java class inside src folder...

MainActivity.java.
................................................................................................................................................................

public class MainActivity extends Activity {

Button imageBtn;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);

imageBtn = (Button) findViewById(R.id.ButtonSelector);
imageBtn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(MainActivity.this,"good Looking",Toast.LENGTH_SHORT).show();
}

});
}

}




1. Normal buuton ...

2. when ,you click on ImageButton change the button state...
try this code...
button_focused_orange image
 
button_pressed_yellow

button_normal_green

Read more

           How to Open Url In Aandroid Web Browser?

try this code...



TextView compnay_info=(TextView)findViewById(R.id.developedby);
compnay_info.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://androidbeginnerpoint.blogspot.in/"));
startActivity(intent);  

}
});
Read more

 Set Custom Listview Height Based on Children programmatically in android


try this code....

public class Utility {

public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
int v = 35;
if (listAdapter == null) {
return;
}

int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {

View listItem = listAdapter.getView(i, null, listView);

if (listItem != null) {
listItem.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
listItem.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

totalHeight += listItem.getMeasuredHeight();
}
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}  
}

the setListViewHeightBasedOnChildren(ListView listView) set on Listview adapter class,explain how to....

             listAdapter = new SelectArralAdapter(this, planetList);
mainListView.setAdapter(listAdapter);
mainListView.setItemsCanFocus(false);
mainListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);


     // same add on 
Utility.setListViewHeightBasedOnChildren(mainListView);


  you can check full tutorial ......


Read more

        Custom ListView with CheckBox in Android

In this blog we will explain how to implement Custom ListView with CheckBox and TextView in android.

1. In this code Add some Extra functions Multiple choice with Counter, how Much select user list Item 1,2,3,4,5 etc according to Requirement. 

2. Explain how to update ListView row via index.

show.

mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
 int counter = 2;
 int j = 0;
 
SparseBooleanArray sparseBooleanArray = mainListView.getCheckedItemPositions();
@Override
public void onItemClick(AdapterView<?> parent, View item,int position, long id) {
mItems list_item = listAdapter.getItem(position);
String str=planet.getName();
SelectViewHolder viewHolder = (SelectViewHolder) item.getTag();  
if (sparseBooleanArray.get(position)==true) {
if (counter > j) {
  viewHolder.getCheckBox().setChecked(true);  
  j++;
  
}else {
mainListView.setItemChecked(position, false);
   
}
} else {
boolean chk=list_item .getChecked();
if(chk==true){
   j--;    
}
}
}
});

Explain source code Step By Step

Step 1. first ,you can create item Entity class inside the src folder.

mItem.java
.............................................................................................................................................................

public class Items {
private String name = "";
private boolean checked = false;
private String subtext = "";
public Items() {
}

public Items(String name) {
this.name = name;
}

public mItems(String name, boolean checked) {
this.name = name;
this.checked = checked;
}
public mItems(String name,String subtext, boolean checked) {
this.name = name;
this.subtext = subtext;
this.checked = checked;
}
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public boolean isChecked() {
return checked;
}

public void setChecked(boolean checked) {
this.checked = checked;
}
public boolean getChecked() {
return checked;
}

public String toString() {
return name;
}

/*public void toggleChecked() {
checked = !checked;
}
*/
public String getSubtext() {
return subtext;
}

public void setSubtext(String subtext) {
this.subtext = subtext;
}
}

Stepe 2. create the ViewHolder class inside src folder

SelectViewHolder.java
...................................................................................................................................................................
public class SelectViewHolder {
private CheckBox checkBox;
private TextView textView;
private TextView subtextView;

public SelectViewHolder() {
}

public SelectViewHolder(TextView textView, TextView subtextView, CheckBox checkBox) {
this.checkBox = checkBox;
this.textView = textView;
this.subtextView = subtextView;
}

public CheckBox getCheckBox() {
return checkBox;
}

public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}

public TextView getTextView() {
return textView;
}

public void setTextView(TextView textView) {
this.textView = textView;
}

public TextView getSubtextView() {
return subtextView;
}

public void setSubtextView(TextView subtextView) {
this.subtextView = subtextView;
}
}
Stepe 3.create a item xml class inside res folder

Simplerow.xml
in this class set the textview and Checkbox.
...................................................................................................................................................................


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/rowTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textSize="16sp"
        android:textStyle="bold" >
    </TextView>

    <CheckBox
        android:id="@+id/CheckBox01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="6sp"
        android:focusable="false"
        android:padding="10dp" >
    </CheckBox>

    <TextView
        android:id="@+id/itempart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>


Stepe 4. create adapter class inside src folder.

SelectArralAdapter.java
...................................................................................................................................................................

public class SelectArralAdapter extends ArrayAdapter<mItems> {
private LayoutInflater inflater;

public SelectArralAdapter(Context context, List<mItems> planetList) {
super(context, R.layout.simplerow, R.id.rowTextView, planetList );
inflater = LayoutInflater.from(context);

}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

mItems item_text = (mItems) this.getItem(position);

CheckBox checkBox;
TextView textView,textitemss = null;


if (convertView == null) {
convertView = inflater.inflate(R.layout.simplerow, null);
textView = (TextView) convertView.findViewById(R.id.rowTextView);
checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);
textitemss=(TextView) convertView.findViewById(R.id.itempart);


convertView.setTag(new SelectViewHolder(textView,textitemss,checkBox));

checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
cb.setChecked(false);
}
});
}

else {

SelectViewHolder viewHolder = (SelectViewHolder) convertView.getTag();
checkBox = viewHolder.getCheckBox();
textView = viewHolder.getTextView();
textitemss= viewHolder.getSubtextView();
}


checkBox.setTag(item_text);
checkBox.setChecked(item_text.getChecked());
textView.setText(item_text.getName());
textitemss.setText(item_text.getSubtext());

return convertView;
}
}





Stepe 5 create the activity_mainclass inside the res folder

activity_main.xml
..................................................................................................................................................................
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools">

            <LinearLayout
                android:id="@+id/layout_dal_subj"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:gravity="center"
                android:orientation="vertical"
                android:paddingBottom="2dp" >

                <TextView
                    android:id="@+id/textView_dal_subj"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:layout_marginTop="3dp"
                    android:gravity="center"
                    android:padding="7dp"
                    android:textSize="24sp"
                    android:textStyle="bold"
                     android:text="Androidbeginner Point"/>

                <ListView
                    android:id="@+id/listView_dal_subj"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="3dp"
                    android:scrollbars="none"
                    tools:ignore="NestedScrolling" >
                </ListView>
            </LinearLayout>


</RelativeLayout>




Stepe 6 create the MainActivity class inside src folder....
MainActivity .java
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.


@SuppressLint("InflateParams")
public class MainActivity extends Activity {

private ListView mainListView,mainListView1,mainListView2;

private ArrayAdapter<mItems> listAdapter;
ArrayList<String> checked = new ArrayList<String>();
ArrayList<String>  list;
ArrayList<mItems> Item_List;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainListView = (ListView) findViewById(R.id.listView_dal_subj);


       Item_List = new ArrayList<mItems>();

 
planetList.add(new mItems("Plain Roti","",false));

planetList.add(new mItems("Tandoori Roti","",false));

planetList.add(new mItems("Rice","",false));

planetList.add(new mItems("fry Rice","",false));

planetList.add(new mItems("Dal Makhni","",false));

planetList.add(new mItems("Sahi Panner","",false));


listAdapter = new SelectArralAdapter(this, Item_List);

mainListView.setAdapter(listAdapter);
mainListView.setItemsCanFocus(false);
mainListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Utility.setListViewHeightBasedOnChildren(mainListView);

mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
int counter = 2;
int j = 0;

  SparseBooleanArray sparseBooleanArray = mainListView.getCheckedItemPositions();
 @Override
  public void onItemClick(AdapterView<?> parent, View item,int position, long id) {

mItems list_item = listAdapter.getItem(position);
String str=list_item.getName();
SelectViewHolder viewHolder = (SelectViewHolder) item.getTag();


if (sparseBooleanArray.get(position)==true) {

if (counter > j) {

  viewHolder.getCheckBox().setChecked(true);
 
  int size = mainListView.getCount();
  int totalture=0;
  Log.i("hello", String.valueOf(size));

for (int i = 0; i < size; i++) {  
   boolean value = sparseBooleanArray.get(i);  
   if(value==true){
   Log.d("all true value", String.valueOf(i)+value);
   totalture++;
       }  
   }

if(totalture==1){
planetList.set(position, new mItems(str,"full plate",true)) ;

}else {
for (int i = 0; i < size; i++) {
mItems indexvalue=listAdapter.getItem(i);
String str3=String.valueOf(indexvalue.toString());
boolean value = sparseBooleanArray.get(i);  
if(value==true){
   planetList.set(i, new mItems(str3,"half plate",true)) ;
   }
}
}    
  listAdapter.notifyDataSetChanged();
 
  j++;

}else {
mainListView.setItemChecked(position, false);
           Toast.makeText(getApplicationContext(), "only 3 checks items",                                                                                                   Toast.LENGTH_LONG).show(); 
}

} else {

boolean chk=list_item.getChecked();
if(chk==true){
int size = mainListView.getCount();
int totalture=0;
for (int i = 0; i < size; i++) {
   boolean value = sparseBooleanArray.get(i);  
   if(value==true){
   totalture++;
   }  
}
for (int i = 0; i< size; i++) {

mItems indexvalue=listAdapter.getItem(i);
String str3=String.valueOf(indexvalue.toString());
boolean value = sparseBooleanArray.get(i);  
if(value==true){  
     if(totalture==1){
       viewHolder.getCheckBox().setChecked(true);
       planetList.set(i, new mItems(str3,"full plate",true)) ;
}
     else {
     viewHolder.getCheckBox().setChecked(true);
         planetList.set(i,new mItems(str3,"half plate",true));
}
       } else {
        viewHolder.getCheckBox().setChecked(false);
         planetList.set(i,new mItems(str3,"",false));
          }
                       }

   listAdapter.notifyDataSetChanged();
   j--;  
}
}
}
});






}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

menu.add(0, 1, Menu.NONE, "Products");
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case 1:

for (int i = 0; i < checked.size(); i++) {
Log.d("pos : ", "" + checked.get(i));
}
break;
}
return super.onOptionsItemSelected(item);
}



}
...................................................................................................................................................................




Update the list Index Onclickitem possition........




Read more