列表视图与细节 [英] Listview with Details

查看:150
本文介绍了列表视图与细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示客户名单列表视图,我增加了一个onClickListner到列表视图,这样我可以得到点击客户端的详细信息。

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.

ListView l = (ListView) findViewById(R.id.jl);
l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                             @Override
                             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                 ClientListView j = JList.get(position);
                                 String mess = "you clicked position " + position + " With Name " + j.GetClientName();
                                 Toast.makeText(Home.this,mess,Toast.LENGTH_LONG).show();
                             }
                         }


);
}

我要显示其信息,但不是在敬酒,我将preFER一些活动,片段或东西一些弹出的国王。

i want to display information but not in toast, i will prefer some activity,fragment or some popup king of thing.

任何人可以帮助?

推荐答案

如果你想通过你在列表中显示客户端名称,你可以从适配器获得ID并使用它。

If you want to pass Client Name which you are displaying in list, you can get id from adapter and use it.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
        long id) {
        String clientName= (String) ((TextView) view
                .findViewById(R.id.client_name)).getText();
        Intent intent = new Intent(this, NextActivity.class);
          intent.putExtra("client", clientName);
            startActivity(intent);

        }
    } 
}

这篇关于列表视图与细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆