Question

I have to open a sub window on clicked list item. This window contain three buttons these are also clickable. See Screenshot.enter image description here

In iphone it is possible using TableRow. Is there way in android like iphone or any different way

Was it helpful?

Solution

create you layout including this expanded View that you want to show on ListItem Click

add the following code to Your LISTViewclick listener where actually want to make it visible

Count is a variable to check if number of times it is clicked is even or odd so as to make it visible and invisible accordingly.

IF((count%2)==0)
{
linearLayout.setvisibilty(View.GONE);
}
else
{
linearLayout.setvisibilty(View.VISIBLE);
}

linearLayout here is your required layout in the screen shot... (design that layout using and set its parent layout visibilty to GONE)

set it to invisible at the starting. and make it visible on itemclick accordingly

giving you a rough idea you can customize the code accordingly

Hope it helps. I had used same tricks many time to make such things happen

OTHER TIPS

I think you have to create your own style and apply that style to your dialog(/sub-window as u call it) and OnListItemClick you have to show this dialog.

If you want to do it like in the screenshot above you will have to make it part of your list item, define it above the normal content of the list item and set that particular layout's visibility to android:visibility="gone". Then when you click on the more button set layout visibility to android:visibility="visible".

Just look @ once here.. may be it can help you.

enter image description here

You might be looking for expandable item. can you see here?

Also see here How to implement expandable panels in Android?

First, apply onItemClickListener to your list view. Then, in onItemClicked(), call a new dialog as I called.

Your List View:

ListView listView = (ListView) findViewById(R.id.listview);
listView.setOnItemClickListener(this); 

In onItemClick:

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    callDialog("Message");
}

Your Dialog coding is:

public static void callDialog(String message){
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.customdialog);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));               

    TextView tvTitle = (TextView) dialog.findViewById(R.id.textview_dialog_title);
    tvTitle.setText("MyDialog..");

    TextView tvText = (TextView) dialog.findViewById(R.id.textview_dialog_text);
    tvText.setText(message);    

    Button buttonDialogYes = (Button) dialog.findViewById(R.id.button_dialog_yes);
    buttonDialogYes.setOnClickListener(new OnClickListener() {          
        public void onClick(View v) {
            // Do some thing.
            dialog.dismiss();
        }
    });

    Button buttonDialogNo = (Button) dialog.findViewById(R.id.button_dialog_no);
    buttonDialogNo.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            //Do some thing
            dialog.dismiss();
        }           
    });
    dialog.show();
}

Develop your custom xml for dialog box, and set it in

dialog.setContentView(R.layout.customdialog);

And it will work fine as you needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top