ListActivity Error

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

ListActivity Error

Postby sudheer1437 » Thu Aug 13, 2009 2:35 pm

Hi...

I am a newbie to android. I am working on ListActivity now.
Actually i have some titles in a list view.
When i click on the title i need to get a new view with more description about that title.

I am really confused how to proceed further...


I used the following code :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.         protected void onListItemClick(ListView l,View v,int position,long id)
  4.  
  5.         {
  6.  
  7.                 super.onListItemClick(l, v, position, id);
  8.  
  9.                 int pos = l.getCheckedItemPosition();;
  10.  
  11.                 String tit = (String)l.getItemAtPosition(pos);
  12.  
  13.                 doTask(tit);
  14.  
  15.         }
  16.  
  17.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

wen i see the value in pos.. it is showing -1...


so please help me out.
sudheer1437
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Sat Aug 08, 2009 7:42 am
Location: India

Top

Re: ListActivity Error

Postby gecu_121 » Wed Aug 19, 2009 7:58 pm

sudheer1437 wrote:When i click on the title i need to get a new view with more description about that title.


hello,
what you want can also be done with param position.
gecu_121
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Jul 30, 2009 2:39 pm

Postby kec6227 » Wed Aug 19, 2009 8:06 pm

Unless you are working with a multiple selection list that actually has check boxes, it will return -1 because there is nothing "checked."

The previous poster has it right: use the parameter "position" from onListItemClick method to get the item position that was clicked.
kec6227
Developer
Developer
 
Posts: 30
Joined: Fri Jul 24, 2009 7:31 pm

Postby sudheer1437 » Thu Aug 20, 2009 8:55 am

Thanks for the reply...

But its not working...
Let me show my xml files...
So that u get an idea..

this is my display view:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.    android:orientation="vertical"
  8.  
  9.    android:layout_width="fill_parent"
  10.  
  11.    android:layout_height="fill_parent"
  12.  
  13.    android:paddingLeft="8dip"
  14.  
  15.    android:paddingRight="8dip">
  16.  
  17.  
  18.  
  19.     <ListView android:id="@android:id/list"
  20.  
  21.        android:layout_width="fill_parent"
  22.  
  23.        android:stackFromBottom="true"
  24.  
  25.        android:layout_weight="1"
  26.  
  27.        android:transcriptMode="normal"
  28.  
  29.        android:clickable="true" android:layout_height="wrap_content" android:choiceMode="multipleChoice">
  30.  
  31. </ListView>
  32.  
  33.  </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
sudheer1437
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Sat Aug 08, 2009 7:42 am
Location: India

Postby sudheer1437 » Thu Aug 20, 2009 8:58 am

On the above ListView I am adding images and text thru TEXTVIEW and IMAGEVIEW which i defined by my own ADAPTER class.

HEnce, my list contains a set of images and their titles.
When i click on that i shuld open another view i.e. textview where i display completely.


I think u understand the problem. CAn u please help how shuld i retrieve the title wen a user clicks on that.
sudheer1437
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Sat Aug 08, 2009 7:42 am
Location: India

Postby mad.dogg » Thu Aug 20, 2009 3:36 pm

What is the error, when does it occur are there any special circumstances?
If it's boring it ain't heavy enough!
mad.dogg
Developer
Developer
 
Posts: 42
Joined: Tue May 20, 2008 2:18 pm
Location: Bulgaria

Top

Postby sudheer1437 » Fri Aug 21, 2009 9:04 am

Thanks for all the guys who responded...
I solved my problem....
sudheer1437
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Sat Aug 08, 2009 7:42 am
Location: India

Postby WarrenFaith » Fri Aug 21, 2009 12:17 pm

Hey,
two things:
first: please present your solution, post your final code
second: use the JAVA and XML button when you post code snippets.

thank you
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby sudheer1437 » Mon Aug 24, 2009 7:16 am

ok..
sorry for the inconvinience caused
sudheer1437
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Sat Aug 08, 2009 7:42 am
Location: India

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests