Note that there are some explanatory texts on larger screens.

plurals
  1. POListview doesnt fire onItemClickListener Event
    primarykey
    data
    text
    <p>i want to place onItemClick listener on my listview...but when i click on listview nothing is happen.. here is my code...can anyone suggest me how can i do this..??</p> <p>Here is my XML FILE (list.xml)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/listbg"&gt; &lt;!-- For the Header Part --&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="35dip" android:background="#EE7621"&gt; &lt;Button android:id="@+id/menuButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/backhome" &gt; &lt;/Button&gt; &lt;TextView android:text="Pantries" android:layout_height="wrap_content" android:layout_width="210dip" android:gravity="center" android:shadowColor="#3B3B3B" android:textColor="#FFFFFF" android:textSize="20dip" android:textStyle="bold"&gt; &lt;/TextView&gt; &lt;Button android:id="@+id/allonmap" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/allonmap" &gt; &lt;/Button&gt; &lt;/LinearLayout&gt; &lt;!-- For the List View --&gt; &lt;TextView android:text="Total Pantries" android:id="@+id/totalPantries" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#F2F2F2" android:background="#B3B3B3"&gt; &lt;/TextView&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt; &lt;ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;!-- For the Footer Part --&gt; &lt;RelativeLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_centerHorizontal="true" android:gravity="bottom"&gt; &lt;ImageView android:id="@+id/footerview" android:src="@drawable/footer" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="center"&gt; &lt;/ImageView&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>here is my Row.xml file</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;RelativeLayout android:id="@+id/mainContent" android:orientation="vertical" android:layout_width="300dip" android:layout_height="fill_parent"&gt; &lt;TextView android:id="@+id/pantryName" android:layout_marginTop="8dip" android:layout_marginLeft="10dip" android:text="name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="16dip" android:textColor="#00AF33" android:gravity="center_vertical" /&gt; &lt;TextView android:layout_below="@id/pantryName" android:textColor="#242424" android:text="address1" android:layout_marginTop="8dip" android:layout_marginLeft="10dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/pantryAddress1" /&gt; &lt;TextView android:layout_below="@id/pantryAddress1" android:textColor="#242424" android:text="address2" android:layout_marginLeft="10dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/pantryAddress2" /&gt; &lt;Button android:layout_below="@+id/pantryAddress2" android:layout_width="wrap_content" android:id="@+id/phbtn" android:layout_marginLeft="10dip" android:layout_height="wrap_content" android:background="@drawable/phonecall" &gt;&lt;/Button&gt; &lt;TextView android:layout_toRightOf="@id/phbtn" android:layout_width="fill_parent" android:layout_below="@id/pantryAddress2" android:textColor="#242424" android:layout_marginLeft="10dip" android:layout_height="wrap_content" android:id="@+id/pantryPhno" /&gt; &lt;TextView android:layout_below="@id/pantryPhno" android:textColor="#242424" android:textSize="10dip" android:layout_marginLeft="12dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/distTime" /&gt; &lt;/RelativeLayout&gt; &lt;Button android:layout_width="wrap_content" android:background="@drawable/next" android:layout_marginTop="45dip" android:layout_marginRight="7dip" android:layout_alignParentRight="true" android:id="@+id/nextBtn" android:layout_height="wrap_content" &gt;&lt;/Button&gt; &lt;/RelativeLayout&gt; </code></pre> <p>here is my java file....</p> <pre><code>package com.pantylocator; import java.net.URL; import java.util.ArrayList; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class PantriesListActivity extends ListActivity { PantreisInfo parsedPantry; ImageAdapter m_adapter; TextView totalPantries; public Button allOnMap,pantrySelection; public static ArrayList&lt;PantreisInfo&gt; m_pantries=new ArrayList&lt;PantreisInfo&gt;(); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); this.m_adapter=new ImageAdapter(this, R.layout.row, m_pantries); setListAdapter(this.m_adapter); setContentView(R.layout.list); ListView lv = getListView(); lv.setTextFilterEnabled(true); Bundle bundle = this.getIntent().getExtras(); String parseURL = bundle.getString("url"); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view,int Position,long id) { Toast.makeText(getApplicationContext(),"Clicked",Toast.LENGTH_LONG).show(); } }); parseURL(parseURL); parsedPantry=PanatriesHandler.getPantries(); PantreisInfo pantry[]=null; pantry =new PantreisInfo[parsedPantry.getID().size()]; for(int i=0;i&lt;parsedPantry.getID().size();i++) { String temp_id=parsedPantry.getID().get(i); String temp_name=parsedPantry.getName().get(i); String temp_add1=parsedPantry.getAddress1().get(i); String temp_add2=parsedPantry.getAddress2().get(i); String temp_phno=parsedPantry.getPhone().get(i); String temp_distTime=parsedPantry.getDistTime().get(i); String temp_lat=parsedPantry.getGeo_lat().get(i); String temp_long=parsedPantry.getGeo_long().get(i); pantry[i]=new PantreisInfo(); pantry[i].setId(temp_id); pantry[i].setName(temp_name); pantry[i].setAddress1(temp_add1); pantry[i].setAddress2(temp_add2); pantry[i].setPhone(temp_phno); pantry[i].setDistTime(temp_distTime); pantry[i].setGeoLat(temp_lat); pantry[i].setGeoLong(temp_long); m_pantries.add(pantry[i]); } totalPantries=(TextView)findViewById(R.id.totalPantries); totalPantries.setText("Total "+parsedPantry.getID().size()+" Pantries"); allOnMap=(Button)findViewById(R.id.allonmap); allOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(PantriesListActivity.this, "Wait..map is being loaded",Toast.LENGTH_SHORT).show(); Intent myIntent; myIntent=new Intent(PantriesListActivity.this, PantriesOnMap.class); startActivityForResult(myIntent, 0); // TODO Auto-generated method stub } }); } void parseURL(String url) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); URL sourceUrl = new URL(url); PanatriesHandler pantriesHandler=new PanatriesHandler(); xr.setContentHandler(pantriesHandler); xr.parse(new InputSource(sourceUrl.openStream())); } catch(Exception e) { System.out.println("==================&gt;Exception Raised==&gt;"+e); } } class ImageAdapter extends ArrayAdapter&lt;PantreisInfo&gt; { private ArrayList&lt;PantreisInfo&gt; items; public ImageAdapter(Context context, int textViewResourceId,ArrayList&lt;PantreisInfo&gt; items) { super(context, textViewResourceId, items); this.items = items; } public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { try { LayoutInflater vi = (LayoutInflater) getSystemServiceContext.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } catch(Exception e) { System.out.println("Excption Caught"+e); } } PantreisInfo p = items.get(position); if (p != null) { TextView name = (TextView) v.findViewById(R.id.pantryName); TextView add1= (TextView) v.findViewById(R.id.pantryAddress1); TextView add2=(TextView)v.findViewById(R.id.pantryAddress2); TextView phno = (TextView) v.findViewById(R.id.pantryPhno); TextView distTime = (TextView) v.findViewById(R.id.distTime); if (name != null) { name.setText(p.getName().get(0).toString()); } if (add1 != null) { add1.setText(p.getAddress1().get(0).toString()); } if (add2 != null) { add2.setText(p.getAddress2().get(0).toString()); } if (phno != null) { phno.setText(p.getPhone().get(0).toString()); } if (distTime!= null) { distTime.setText("Distribution Time: "+p.getDistTime().get(0).toString()); } } return v; } } } </code></pre> <p>thanks in advance.....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload