Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
OPAL HUTCHINSON
Courses Plus Student 2,611 PointsPhone Call from list view
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.app.ListActivity;
import android.widget.ListView;
public class Agriculture extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agriculture);
String [] AgricultureNumbers ={
"Administration 347-648-2999",
"Legal office 347-895-3456",
"Permanent Secatery 347-852-6665"
};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,AgricultureNumbers);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + AgricultureNumbers[position]));
startActivity(intent);
}
}
I'm trying to make a phone call from the list of numbers. If the user taps on any number in the list it would call the selected number. However I have an error. "AgricultureNumbers" in my intent is in red. Can anyone assist?