Skip to content Skip to sidebar Skip to footer

How Open Sub Window With Three Buttons On Clicked List Item Like Shown In Screenshot With Red Square

I have to open a sub window on clicked list item. This window contain three buttons these are also clickable. See Screenshot. In iphone it is possible using TableRow. Is there way

Solution 1:

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


Solution 2:

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.


Solution 3:

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".


Solution 4:


Solution 5:

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.


Post a Comment for "How Open Sub Window With Three Buttons On Clicked List Item Like Shown In Screenshot With Red Square"