How open sub window with three buttons on clicked list item like shown in screenshot with red square

与世无争的帅哥 提交于 2019-12-11 03:37:36

问题


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 in android like iphone or any different way


回答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




回答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.




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




回答4:


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

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

Also see here How to implement expandable panels in Android?




回答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.



来源:https://stackoverflow.com/questions/15495178/how-open-sub-window-with-three-buttons-on-clicked-list-item-like-shown-in-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!