[VIDEO-Tut] - Querying and Displaying the CallLog

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Formatting CallLog Date and Time (Absolute)

Postby iPaul Pro » Sat Mar 28, 2009 4:38 pm

Okay, So I found out that using FormatDate (SimpleDateFormat) is not preferred for loops with a lot of information (that is why my app was taking so long to load)

I have found alternatives.

For absolute date and time, try this (not sure if this is the best way but it works and is fast):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.      long created = c.getLong(dateColumn);
  3.  
  4.         Date nDate = new Date(created);                                        
  5.  
  6.         Calendar cal = Calendar.getInstance();
  7.  
  8.         cal.setTime(nDate);
  9.  
  10.        
  11.  
  12.                 int iMonth = cal.get(Calendar.MONTH) + 1;
  13.  
  14.                 int iDay = cal.get(Calendar.DAY_OF_MONTH);
  15.  
  16.                 int iDayName = cal.get(Calendar.DAY_OF_WEEK);
  17.  
  18.                 int iHour = cal.get(Calendar.HOUR);
  19.  
  20.                 int iMin = cal.get(Calendar.MINUTE);
  21.  
  22.                 int iAmPm = cal.get(Calendar.AM_PM);
  23.  
  24.        
  25.  
  26.                
  27.  
  28.                     String month = Integer.toString(iMonth);
  29.  
  30.                         if(iMonth == 1){
  31.  
  32.                             month = "January";
  33.  
  34.                         }
  35.  
  36.                     if(iMonth == 2){
  37.  
  38.                             month = "February";
  39.  
  40.                     }
  41.  
  42.                     if(iMonth == 3){
  43.  
  44.                             month = "March";
  45.  
  46.                     }
  47.  
  48.                         if(iMonth == 4){
  49.  
  50.                             month = "April";
  51.  
  52.                         }
  53.  
  54.                     if(iMonth == 5){
  55.  
  56.                             month = "May";
  57.  
  58.                     }
  59.  
  60.                     if(iMonth == 6){
  61.  
  62.                             month = "June";
  63.  
  64.                     }
  65.  
  66.                         if(iMonth == 7){
  67.  
  68.                             month = "July";
  69.  
  70.                         }
  71.  
  72.                     if(iMonth == <img src="http://www.anddev.org/images/smilies/cool.png" alt="8)" title="Cool" />{
  73.  
  74.                             month = "August";
  75.  
  76.                     }
  77.  
  78.                     if(iMonth == 9){
  79.  
  80.                             month = "September";
  81.  
  82.                     }
  83.  
  84.                         if(iMonth == 10){
  85.  
  86.                             month = "October";
  87.  
  88.                         }
  89.  
  90.                     if(iMonth == 11){
  91.  
  92.                             month = "November";
  93.  
  94.                     }
  95.  
  96.                     if(iMonth == 12){
  97.  
  98.                             month = "December";
  99.  
  100.                         }
  101.  
  102.  
  103.  
  104.             String dayName = Integer.toString(iDayName);
  105.  
  106.                         if(iDayName == 1){
  107.  
  108.                             dayName = "Sunday";
  109.  
  110.                         }
  111.  
  112.                         if(iDayName == 2){
  113.  
  114.                             dayName = "Monday";
  115.  
  116.                         }
  117.  
  118.                         if(iDayName == 3){
  119.  
  120.                             dayName = "Tuesday";
  121.  
  122.                         }
  123.  
  124.                         if(iDayName == 4){
  125.  
  126.                             dayName = "Wednesday";
  127.  
  128.                         }
  129.  
  130.                         if(iDayName == 5){
  131.  
  132.                             dayName = "Thursday";
  133.  
  134.                         }
  135.  
  136.                         if(iDayName == 6){
  137.  
  138.                             dayName = "Friday";
  139.  
  140.                         }
  141.  
  142.                         if(iDayName == 7){
  143.  
  144.                             dayName = "Saturday";
  145.  
  146.                         }
  147.  
  148.                        
  149.  
  150.                 String day = Integer.toString(iDay);
  151.  
  152.                         if(iDay < 10){
  153.  
  154.                             day = "0" + day;
  155.  
  156.                         }
  157.  
  158.        
  159.  
  160.                 String hour = Integer.toString(iHour);
  161.  
  162.                         if(iHour == 0){
  163.  
  164.                             hour = "12";
  165.  
  166.                         }
  167.  
  168.        
  169.  
  170.                 String min = Integer.toString(iMin);
  171.  
  172.                         if(iMin < 10){
  173.  
  174.                             min = "0" + min;
  175.  
  176.                         }
  177.  
  178.        
  179.  
  180.                 String amPm = Integer.toString(iAmPm);
  181.  
  182.                         if(iAmPm == 0){
  183.  
  184.                                 amPm = "AM";
  185.  
  186.                         } else {
  187.  
  188.                                 amPm = "PM";
  189.  
  190.                         }
  191.  
  192.  
  193.  
  194.         String myDate = dayName + ", " + month + " " + day + "," + " " + cal.get(Calendar.YEAR);
  195.  
  196.         String myTime = hour + ":" + min + " " + amPm;
  197.  
  198.                            
  199.  
  200. callList.add(new IconifiedText(callerName, callerPhoneNumber, myDate, myTime, currentIcon));                                
Parsed in 0.044 seconds, using GeSHi 1.0.8.4


This is will ouput the date like so: Saturday, March 28, 2009
and the time: 11:30 AM

IMPORTANT - I have modified the IconifiedTextListAdapter.java, IconifiedText.java, and IconifiedTextView.java to accept the extra "myDate" and "myTime" views. This must be done first, if you wish to implement my date and time fix (HINT - just 'duplicate' the existing TextViews).

If anyone needs help on making this work, feel free to ask me how to do it. I promise to answer, whether or not I know how to help.

I have a solution for relative dates and times, however it requires a ViewBinder and SimpleCursorAdapter to be used, and I have yet to figure out how to incorporate with the IconifiedTextListAdapter.

Hope this helps someone.
- iPaul Pro
iPaul Pro
Developer
Developer
 
Posts: 33
Joined: Sun Mar 15, 2009 9:01 pm

Top

Set an ACTION_CALL Intent to onListItemClick

Postby iPaul Pro » Sat Mar 28, 2009 10:10 pm

Hello again,

I'm trying to make an onListItemClick that would call the Calls.NUMBER of the selected list row. Here's what I have (after onCreate):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.                
  9.  
  10.                 Intent i = new Intent(Intent.ACTION_CALL);
  11.  
  12.                
  13.  
  14.                 Cursor c = (Cursor) ((IconifiedTextListAdapter)getListAdapter()).getItem(position);
  15.  
  16.                 long phoneNum = c.getLong(c.getColumnIndex(Calls.NUMBER));
  17.  
  18.                
  19.  
  20.                 i.setData(ContentUris.withAppendedId(
  21.  
  22.                     android.provider.CallLog.Calls.CONTENT_URI, phoneNum));
  23.  
  24.                
  25.  
  26.                 this.startActivity(i);
  27.  
  28.         }
  29.  
  30.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Any help, hints, or links would be greatly appreciated.

Thanks
iPaul Pro
Developer
Developer
 
Posts: 33
Joined: Sun Mar 15, 2009 9:01 pm

Postby iPaul Pro » Tue Apr 07, 2009 5:58 pm

How can I set and onListItemClick to load an intent, bundling the callerName variable?

Here's what I've tried:

1.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.  
  9.  
  10.                 Intent intent = new Intent(this, MyActivity.class);
  11.  
  12.                 Cursor cursor = (Cursor) itla.getItem(position);
  13.  
  14.                  Bundle b = new Bundle();
  15.  
  16.                  String cCallerName = cursor.getString(cursor.getColumnIndex(Calls.CACHED_NAME));
  17.  
  18.         b.putString("CallerName", cCallerName);
  19.  
  20.         intent.putExtras(b);
  21.  
  22.                 startActivity(intent);
  23.  
  24.         }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


- Force close,

2.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.  
  9.  
  10.                 Intent intent = new Intent(this, MyActivity.class);
  11.  
  12.                 Cursor cursor = (Cursor) ((IconifiedTextListAdapter)getListAdapter()).getItem(position);
  13.  
  14.                  Bundle b = new Bundle();
  15.  
  16.                  String cCallerName = cursor.getString(cursor.getColumnIndex(Calls.CACHED_NAME));
  17.  
  18.         b.putString("CallerName", cCallerName);
  19.  
  20.         intent.putExtras(b);
  21.  
  22.                 startActivity(intent);
  23.  
  24.         }
  25.  
  26.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


- again, force close.

3.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.  
  9.  
  10.                 Intent intent = new Intent(this, MyActivity.class);
  11.  
  12.                 c = (Cursor) ((IconifiedTextListAdapter)getListAdapter()).getItem(position);
  13.  
  14.                  Bundle b = new Bundle();
  15.  
  16.                  String cCallerName = c.getString(c.getColumnIndex(Calls.CACHED_NAME));
  17.  
  18.         b.putString("CallerName", cCallerName);
  19.  
  20.         intent.putExtras(b);
  21.  
  22.                 startActivity(intent);
  23.  
  24.         }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


- you guessed it.

4.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.  
  9.  
  10.                 Intent intent = new Intent(this, MyActivity.class);
  11.  
  12.                 c = (Cursor) itla.getItem(position);
  13.  
  14.                  Bundle b = new Bundle();
  15.  
  16.         b.putString("CallerName", callerName);
  17.  
  18.         intent.putExtras(b);
  19.  
  20.                 startActivity(intent);
  21.  
  22.         }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


- Nope.

Now I am still new to Java/Android and do not fully understand how to debug using my LogCat output.

When I try to bundle the variable, without getting the item postition, it works, but only display the name from the first database result (oldest call):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.  
  9.  
  10.                 Intent intent = new Intent(this, MyActivity.class);
  11.  
  12.                  Bundle b = new Bundle();
  13.  
  14.         b.putString("CallerName", callerName);
  15.  
  16.         intent.putExtras(b);
  17.  
  18.                 startActivity(intent);
  19.  
  20.         }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


So my issue definitely lies in my attempt to getItem(position) of the IconifiedTextListAdapter.

I've tried many things beyond whats posted above like closing the first cursor, trying to addExtra to the intent without a bundle. Nothing works.

Please, any help would be greatly appreciated.
iPaul Pro
Developer
Developer
 
Posts: 33
Joined: Sun Mar 15, 2009 9:01 pm

Postby iPaul Pro » Sun Apr 12, 2009 8:20 am

Is there anyone that can help me figure out how to correctly bundle cursor items from the IconifiedTextListAdapter?

I'd like to know how to pass the "cached name" of the selected list item to a sub-activity using an onListItemClick.

I have no problem bundling static string between activities. It is only when I try to pass the position of the list adapter that I run into issues.

The second activity could literally just display the bundled string(s) in a simple, un-styled text view.

Please, I have been stuck on this for days. Any help or links greatly appreciated.

Please..
iPaul Pro
Developer
Developer
 
Posts: 33
Joined: Sun Mar 15, 2009 9:01 pm

Postby iPaul Pro » Fri Apr 17, 2009 7:49 pm

I figured it out. This topic title should be changed to the "iPaul Pro Trial and Error Thread" :P

To pass the position of the cursor items from the IconifiedTextListAdapter to a sub-activity (Pass the chosen Name):

In CallLogDisplayer.java:

before OnCreate
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private Cursor c = null;
Parsed in 0.036 seconds, using GeSHi 1.0.8.4

(then remove the Cursor declaration at the query)

after OnCreate
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onListItemClick(ListView l, View v, int position, long id) {
  5.  
  6.                 super.onListItemClick(l, v, position, id);
  7.  
  8.                
  9.  
  10.                 c.moveToPosition(position);
  11.  
  12.                 Intent i = new Intent(this, SubActivity.class);
  13.  
  14.                 i.putExtra("CallerName", c.getString(nameColumn));
  15.  
  16.                 startActivity(i);
  17.  
  18.         }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


and in your SubActivity.java:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String name = getIntent().getStringExtra("CallerName");
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


That's it! I was so close - but that's how these things go.

Feel free to ask for clarification.
- iPaul Pro
iPaul Pro
Developer
Developer
 
Posts: 33
Joined: Sun Mar 15, 2009 9:01 pm

isFirst() is returning false always!!!!!!!!!!!

Postby sheshi85 » Wed Jun 10, 2009 11:30 am

I tried other methods like moveTofirst.but it is not showing the output in the emulator.can anyone please address this error!!!
thanks in advance!!!!!!!!
sheshi85
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Jun 08, 2009 11:17 am

Top

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby chico » Thu Sep 17, 2009 9:27 pm

Hi Plusminus,
great tutorial,
I had one question
I want to only checked for the missed calls that has NOT yet been checked by the user (new missed calls). The way you have the code right now it will always count ALL the missed calls that are present in the call log. What I mean is if there is a missed call and I see a missed call icon on my status bar. Once I look at the call log , the status bar icon is cleared. But when we use the code provided by you it will still notify the already "viewed missed call" as missed call.

Thanks in advance for your help

Chico
chico
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Sep 17, 2009 9:20 pm

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby dinakar » Wed Sep 29, 2010 10:59 am

iam getting the application callog (processcom.android.projects) has stopped unexpectedly please try again.
dinakar
Freshman
Freshman
 
Posts: 2
Joined: Wed Sep 29, 2010 5:57 am

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby dinakar » Fri Oct 01, 2010 7:51 am

the appliaction calllog process
package name ) has stopped unexpectedly pls try again
error is coming
iam unable to find the error
dinakar
Freshman
Freshman
 
Posts: 2
Joined: Wed Sep 29, 2010 5:57 am

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby droid42 » Mon Nov 15, 2010 2:34 pm

How can I simply map from call log entry to contact id? My intent is to add contact information like photo to th call log list.
droid42
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Nov 15, 2010 2:19 pm

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby adameve24 » Thu Dec 16, 2010 8:35 pm

can i query and display the call log using any adb command or C language cos i donno java
adameve24
Developer
Developer
 
Posts: 29
Joined: Wed Dec 15, 2010 12:32 pm

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby sem_thesis » Tue Mar 29, 2011 7:01 pm

Hi!


I tried to implement the CallLog feature as a service, also using the cursors and this time using a listener.
Now - the values 'phonenumber' and 'name' are not displayable for some reason.
Also - as I start writing this stuff in a database - the app crashes.
Can you make any sense of it?



Here goes my Listener class:
Code: Select all
   private class MyPhoneStateListener extends PhoneStateListener {
      
       Calendar calendar = new GregorianCalendar();
       int i = calendar.get(Calendar.MONTH) + 1;
      
      String date = calendar.get(Calendar.DATE) + "." + i + "." + calendar.get(Calendar.YEAR);
      String time = calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);

        String name;
        String phonenumber;
        String duration;
        String callclassification;
        
        public void onCallStateChanged(int state,String incomingNumber){
   
              Cursor c = getContentResolver().query(
                        android.provider.CallLog.Calls.CONTENT_URI,
                        null,
                        null,
                        null,
                        android.provider.CallLog.Calls.DATE+ " DESC");
          
           // Collect new Phone Logs //
           name = android.provider.CallLog.Calls.CACHED_NAME;
           phonenumber = android.provider.CallLog.Calls.NUMBER;
           duration = android.provider.CallLog.Calls.DURATION;
          
           Log.d(TAG, "STATE HAS CHANGED!");

          
           switch(state){
              case TelephonyManager.CALL_STATE_IDLE:
                 Log.d(TAG, "---booooooo-----");
                 break;
              case TelephonyManager.CALL_STATE_OFFHOOK:
                 callclassification = "Outgoing Call";
                 Log.d(TAG, "Calling somebody");
                 Log.d(TAG, date);
                 Log.d(TAG, time);
                 Log.d(TAG, callclassification);
                 Log.d(TAG, name);
                 Log.d(TAG, phonenumber);

                 break;
          case TelephonyManager.CALL_STATE_RINGING:
                Log.d(TAG, "RINGING");
                 Log.d(TAG, date);
                 Log.d(TAG, time);
                 callclassification = "Incoming Call";
                 Log.d(TAG, callclassification);
                 Log.d(TAG, name);
                 Log.d(TAG, phonenumber);
                break;
           }
          
          
           // Write new Phone Logs in Database //
          
           db.open();
           db.insertCallLogs(date, time, name, phonenumber, duration, callclassification);
          
          
        }

   }


PS: Source code of the whole app is given in the attachment.

Attachments
MyCallLog.zip
(67.35 KiB) Downloaded 95 times
sem_thesis
Freshman
Freshman
 
Posts: 9
Joined: Sun Mar 06, 2011 12:29 pm

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby zeroARM000 » Tue Apr 12, 2011 3:27 pm

how to get a list item position by clicking the button inside it?

Hi guys, actually I've read some previous questions about this...

this is the code that I use
Code: Select all
auto = (ListView)findViewById(R.id.auto);
String[] projection = new String[] {Browser.BookmarkColumns._ID,Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.URL};

    String[] displayFields = new String[] {Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL};

    int[] displayViews = new int[] { R.id.text1,R.id.text2 };

    Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI,projection, null, null, null);

    //auto.setAdapter(new SimpleCursorAdapter(this, R.layout.mylist, cur,displayFields, displayViews));

    myAdapter apt = new myAdapter(this, R.layout.mylist, cur,displayFields, displayViews);
    auto.setAdapter(apt);


and class myAdapter
Code: Select all
class myAdapter extends SimpleCursorAdapter{

    private Cursor c;
    private Context context;


    public myAdapter(Context context, int layout, Cursor c, String[] from,
            int[] to) {
        super(context, layout, c, from, to);
        // TODO Auto-generated constructor stub
        this.c = c;
        this.context = context;
        AutoList att = new AutoList();
        mListView = att.auto;

    }

    @Override
    public View getView(int pos, View inView, ViewGroup parent) {
           View vix = inView;

           if (vix == null) {
                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                vix = inflater.inflate(R.layout.mylist, null);
           }
           this.c.moveToPosition(pos);     

           String title = this.c.getString(this.c.getColumnIndex(Browser.BookmarkColumns.TITLE));

           String cont = this.c.getString(this.c.getColumnIndex(Browser.BookmarkColumns.URL));

               TextView text1 = (TextView) vix.findViewById(R.id.text1);
               text1.setText(title);
               TextView text2 = (TextView) vix.findViewById(R.id.text2);
               text2.setText(cont);
               Button butt = (Button) vix.findViewById(R.id.button);
               butt.setOnClickListener(mButt);
               return vix;
    }

    private OnClickListener mButt = new OnClickListener() {
        @Override
        public void onClick(View v) {
        final int position = mListView.getPositionForView((View) v.getParent());
            Log.v("BUTT", "Title clicked, row "+position);
        }
    };


However, when I click the button, I still get a lot of errors like this:
Code: Select all
04-10 22:30:55.152: ERROR/AndroidRuntime(695): FATAL EXCEPTION: main
04-10 22:30:55.152: ERROR/AndroidRuntime(695): java.lang.NullPointerException
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at             com.auto2.AutoList$myAdapter$1.onClick(AutoList.java:113)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.view.View.performClick(View.java:2408)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.view.View$PerformClick.run(View.java:8816)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.os.Handler.handleCallback(Handler.java:587)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   android.os.Handler.dispatchMessage(Handler.java:92)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.os.Looper.loop(Looper.java:123)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invokeNative(Native Method)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at java.lang.reflect.Method.invoke(Method.java:521)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-10 22:30:55.152: ERROR/AndroidRuntime(695):     at   dalvik.system.NativeStart.main(Native Method)


That's it! I hope it won't be so difficult to be figured out!

Thanks!
zeroARM000
Freshman
Freshman
 
Posts: 5
Joined: Tue Apr 05, 2011 10:01 am

Re: [VIDEO-Tut] - Querying and Displaying the CallLog

Postby winwinhost » Sat Jun 25, 2011 3:21 am

Sorry If missed this in the thread, but how do you exactly add calls to your call log?
When my app starts its call log is empty.
Of course I am talking about the emulator and not my actual phone.
winwinhost
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 25, 2011 3:16 am

onListItemClick how??

Postby gilzin » Thu Oct 06, 2011 7:33 am

hi there
can some one plz help me understand how i can use the onListItemClick().
every time i try i am getting the record id or index instead of the number or name... :(

i am trying to use this code:
Code: Select all
@Override
   protected void onListItemClick(ListView l, View v, int position, long id) {
      super.onListItemClick(l, v, position, id);
      // Get the item that was clicked
      Object o = this.getListAdapter().getItem(position);
      String keyword = o.toString();
      Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
            .show();
gilzin
Freshman
Freshman
 
Posts: 3
Joined: Thu Oct 06, 2011 7:18 am

Top
PreviousNext

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests