I am currently working on assignment from my lecturer, makes a program like the phone book.
I've created an xml to create the list (as i attached)
<layanan>
<layanan nama="Ambulance" tel="118"/>
<layanan nama="Emergency" tel="112"/>
<layanan nama="PLN - Electricity" tel="123"/>
<layanan nama="Telkom - Telecomunication" tel="117"/>
<layanan nama="Interlocal Information" tel="106"/>
<layanan nama="Local Information" tel="108"/>
<layanan nama="Time" tel="103"/>
<layanan nama="Police" tel="110"/>
<layanan nama="Fire Department" tel="113"/>
<layanan nama="PMI - Indonesian Red Cross" tel="0214207051"/>
<layanan nama="SAR - Search and Rescue" tel="115"/>
<layanan nama="Telkom - Phone Billing" tel="109"/>
</layanan>
then this partial program that i made
import java.io.InputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class layanan extends ListActivity {
TextView selection;
ArrayList<String> items = new ArrayList<String>();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layanan);
selection=(TextView)findViewById(R.id.selection);
try {
InputStream in = getResources().openRawResource(R.raw.layanan);
DocumentBuilder builder = DocumentBuilderFactory
.newInstance()
.newDocumentBuilder();
Document doc = builder.parse(in, null);
NodeList words = doc.getElementsByTagName("layanan");
for (int i=1;i<words.getLength();i++) {
items.add(((Element)words.item(i)).getAttribute("nama"));
}
in.close();
}
catch (Throwable t) {
t.printStackTrace();
}
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,items));
}
public void onListItemClick(ListView parent, View v, int
position,long id) {
switch (position) {
case 0:
Intent DialAmbulance = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"));
DialAmbulance.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(DialAmbulance);
break;
}
}}
I wanna ask, how can i use the "tel" on my xml raw resources to be the uri.parse, so that if i press the list, it will launch dial action??
can you explain me how to do it?? with the code i mean....
sorry if my question looks so very stupid. i new with this matter...i need your help
thank you very much for the help...

