开发者

Index of the item that is clicked in ListView

开发者 https://www.devze.com 2023-02-12 01:01 出处:网络
Android: Hello, i am trying to get index of the item that is clicked but i don\'t know how i can do it.

Android: Hello, i am trying to get index of the item that is clicked but i don't know how i can do it. I want if i click on any item in listview it will open SmsManager with number of this item(Phone Number). Can somebody tell me how i can do it?

There is source code:

 list1.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int position,
                    long id) {
                SmsManager m = SmsManager.getDefault();
                Uri uriSMSURIs = Uri.parse("content://sms/inbox");
                Cursor cc = getContentResolver().query(uriSMSURIs, null, null, null, null);
                String phoneNumber  = cc.getString(cc.getColumnIndex("address"));
                m.sendTextMessage(phoneNumber , null, phoneNumber , 开发者_开发知识库null, null);


            }

        });


The "index of the item witch [sic] is clicked" is the position parameter supplied to onItemClick().


Implement

onListItemClick

    @Override
    protected void onListItemClick(ListView l, View v, final int position, long id) {
        super.onListItemClick(l, v, position, id);  

Log.i("the Item clicked is :: ",  position);

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消