AlertDialog - selected item

by Ajay » Thu, 22 Apr 2010 18:58:31 GMT

Sponsored Links
   I have an AlertDialog with a list of selectable items and a OK
button. How can I get the selected option, when the user clicks the OK

Thank you,


AlertDialog - selected item

by Mark Murphy » Thu, 22 Apr 2010 19:02:56 GMT


Try calling getListView() on the AlertDialog. From there, you should be
able to call getCheckedItemPosition().

Mark Murphy (a Commons Guy)  | 

Android Consulting: 


Sponsored Links

AlertDialog - selected item

by Ajay » Thu, 22 Apr 2010 19:16:33 GMT

 Thanks a lot again for a very quick reply!! You are a life saver :-)


Other Threads

1. Need help in calling a SAP library.

Hello all,

I'm facing a problem in connection of android and SAP.
SAP has provided a java connector to connect to SAP called JCO.
For this there are 2 steps that needs to be followed:
1.) add reference of sapjco.jar in your project.
2.) Load library in unix.

I've already done the first step but for the second part i'm note sure
how to do it..
Can someone help to load an external library in android.



2. Twitter4j internet access

Hi guys, Started coding up a simple android app. Part of it pulls the
users last 20 tweets and saves them to a database. When I run this,
statuses = twitter.getUserTimeline(); throws an exception its handled
and prints out: failed to get timeline-permission denied. When I run
the same code non-android, it works fine. I'm a little bit baffled.
Could android be limiting the network connection? Im using some
database helper classes, haven't included the code because the
exception is thrown before any of these are even involved :(. Someone
suggested fixing my manifiest to allow net access so I added: <uses-
permission android:name="android.permission.INTERNET" /> Still giving
the same error though. Any help would be much appreciated. Heres the

<pre><code>import twitter4j.Paging;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;

import java.util.ArrayList;
import java.util.Date;

import android.os.Bundle;
import android.widget.ArrayAdapter;
public class  TwitterTest extends ListActivity{
 private ArrayList&lt;String&gt; queryString;
 private DatabaseQuery query;

 /* returns date in string format-without time */
 String getThisYearDate(Date d){
  String x = d.toString();
  String y= x.substring(0, 11);
  String z =x.substring(17);
  String a = y.concat(z);
  return a;

 public void onCreate(Bundle savedInstanceState) {

  query = new DatabaseQuery(this);

  /*If file exists then tables in db created successfully*/

  File file = new File("exists.txt");

  boolean success = file.exists();

  if (success==false) {
   try {

    ArrayList&lt;Status&gt; statuses = new ArrayList&lt;Status&gt;();

    Twitter twitter = new TwitterFactory().getInstance("USERNAME",

    statuses = twitter.getUserTimeline();

    /* adds status data to database*/
    for(Status s: statuses){

     query.appendData("Text", s.getText());
     query.appendData("Date", this.getThisYearDate(s.getCreatedAt()));
     query.appendData("ID",String.valueOf(s.getId()) );

   catch (TwitterException te) {
    System.out.println("Failed to get timeline: " + te.getMessage());

    System.exit( -1);
    boolean created = file.createNewFile();
   catch (IOException e) {



   queryString = query.getData(new String[]
{"Text"},this.getThisYearDate(new Date()), null, null, null, "Date", "
   try {
   } catch (Throwable e) {

  } else {
   // File already exists
   queryString = query.getData(new String[]
{"Text"},this.getThisYearDate(new Date()), null, null, null, "Date", "
   try {
   } catch (Throwable e) {


 // Set the ListView
 setListAdapter(new ArrayAdapter&lt;String&gt;(this,
   android.R.layout.simple_list_item_1, queryString));


3. build android.jar with all hidden and deprecated APIs

4. Can't Export Android Projects Anymore

5. Terminal Server access from an Android Tablet PC

6. Flash Player + PhoneGap

7. How much does an Nexus One cost?