Listview with Details

后端 未结 4 1846
予麋鹿
予麋鹿 2021-01-17 02:05

i have a Listview which displays list of clients, i have added an onClickListner to Listview so that i can get the detailed information of clicked client.

Li         


        
4条回答
  •  囚心锁ツ
    2021-01-17 02:56

    Use ths code:

    l.setOnItemClickListener(new OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
                ClientListView j = JList.get(position);
                String mess = "you clicked position " + position + " With Name " + j.GetClientName();
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityName.this);//Your activity name
    
        // set title
        alertDialogBuilder.setTitle("Hello!");
    
        // set dialog message
        alertDialogBuilder.setMessage(mess)
                .setCancelable(false)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, close
                        // current activity
                    }
                });
    
        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
    
        // show it
        alertDialog.show();
            }
        });
    

    Hope this will work..

提交回复
热议问题