Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get phone number from contact?
    primarykey
    data
    text
    <p>I have two <code>String[]</code>, one with names and the other one with phone number. If I select one name from list, how can I call phone number of that person from Dialog box. For example, first person in first <code>string[]</code> has a phone number of <code>second[]</code>. How to get that number?</p> <pre><code>package com.mkyong.android; import android.app.AlertDialog; import android.app.ListActivity; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class ListFruitActivity extends ListActivity { static final String[] Imena = new String[] { "Aleksandar Panic", "Dubravka Protic", "Milutin Panic", "Jelica Panic", "Nemanja Gagic", "Doris Dragojevic", "Milica Protic", "Kiki Beba", "Dule Savic", "Miroslav Miskovic", "Petar Djuric", "Dragoslav Joksimovic", "Petar Petrovic" }; static final String[] Brojevi=new String[] { "0638638045", "062450050", "065045324", "05443", "06535475", "564218", "546567", "514574","5454333","444787","413133","354867","24879"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_fruit, Imena)); ListView listView = getListView(); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { AlertDialog.Builder adb=new AlertDialog.Builder(ListFruitActivity.this); adb.setTitle("Odabir"); adb.setMessage("Izabrali ste profesora "+parent.getItemAtPosition(position)); adb.setPositiveButton("Call",new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int which) { Intent i=new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+651234567")); //here is the problem, how to get the right number startActivity(i); } }); adb.show(); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload