I am trying to make a custom dialog with listview which is going to contain checkboxes and textviews and i just couldnt find a reasonable tutorial to do it , any help or hints w
It sounds like what your looking for is multiple choice mode for the ListView. Without knowing that phrase it's pretty hard to get a good example, but here's another SO question with answers that might help you out.
(Doing this in a Dialog is essentially the same process as in the selected answer's example.)
ListView myList = new ListView(Activity.this);
myList.setAdapter(adapter);
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this);
builder.setView(myList);
Dialog d = builder.create();
d.show();
you can specify the textviews and checkboxes and whatever else in the adapter.
private void showPopUp()
{
final AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("");
LayoutInflater inflater = getLayoutInflater();
final View PopupLayout = inflater.inflate(R.layout.yourxml, null);
helpBuilder.setView(PopupLayout);
final AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
jobList = (ListView)PopupLayout.findViewById(R.id.list);
mylist = new ArrayList<HashMap<String, String>>();
for(int i=0;i<arraylist.size();i++)
{
map = new HashMap<String, String>();
map.put("name", arraylist.get(i));
mylist.add(map);
}
sd = new SimpleAdapter(activity.this,mylist,R.layout.jobslist,
new String[]{"name"},new int[]{R.id.jobText});
jobList.setAdapter(sd);
}
joblist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lin01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:padding="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/jobText"
android:layout_width="0dp"
android:text="@string/jobtype"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:textColor="#000"
android:layout_height="50dp"/>
<CheckBox
android:id="@+id/chk"
android:layout_width="wrap_content"
android:text=""
android:gravity="center_vertical|right"
android:layout_height="wrap_content"/>
</LinearLayout>
you can call this showPopUp();
function wherever you want to display the alert dialog with listview. please note that there will be the arraylist which you can add items to it to show the items in a list