android - How to dial phone numbers which are contained in two line ListView -
i trying populate 2 line list name , numbers.
i have finished part, want dial numbers when clicked on particular items.
i know method single line list find hard 2 lines.
here's screenshot: http://imgur.com/vn6zdvu
package com.example.tushar.twolinelist; import android.app.listactivity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.listview; import android.widget.simpleadapter; import java.util.arraylist; import java.util.hashmap; public class mainactivity extends listactivity { private simpleadapter sa; arraylist<hashmap<string, string>> list = new arraylist<hashmap<string, string>>(); listview lv; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //setcontentview(r.layout.list1); lv= (listview) findviewbyid(r.id.listview); hashmap<string, string> item; (int = 0; < nameandmubers.length; i++) { item = new hashmap<string, string>(); item.put("line1", nameandmubers[i][0]); item.put("line2", nameandmubers[i][1]); list.add(item); } sa = new simpleadapter(this, list, r.layout.list1, new string[]{"line1", "line2"}, new int[]{r.id.text1, r.id.text2}); setlistadapter(sa); } private string[][] nameandmubers = {{"mehadi", "0123565"}, {"sagor", "01615"}, {"ovi", "2356565"}, {"hamidul", "25341"}, }; }
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/listview" android:layout_marginbottom="10dp" android:layout_gravity="center_horizontal" /> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:textcolor="#ff1483d1" android:textsize="25dp" android:padding="0dp" android:text="@string/hello" android:id="@+id/text1"/> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:textcolor="#ffffb14d" android:padding="0dp" android:textsize="22dp" android:text="@string/hello" android:id="@+id/text2"/> </linearlayout>
try !
lv.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1,int position, long arg3) { string mynumber= //use mutlidimensional array eg. string value 'position' intent intent = new intent(intent.action_call, uri.parse(mynumber)); startactivity(intent); }
it may !.
Comments
Post a Comment