• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ListView Help: Resource Not Found

piper210

Lurker
Apr 21, 2012
4
0
Hi people.

I am working on a project an am currently blocked. I created an arraylist with the info I want displayed in the listview. I used an array adapter and put that in the setListAdapter. All this is done by the book.

However, when I run it, it goes through the whole program and then gives me an error that it can't find the list_item.xml resource. I check the path that it gave an it is there. I tried cleaning the project and restarting the computer but nothing works.

Does anyone have any ideas as to how I can fix this? I'd really appreciate the help.

Additional Info: I have been doing tests and it I learned that the program messes up when I use setListAdapter(value).

fyi: The variable value is what i get from the array adapter.

Hope this info is useful. I really need some help to solve this. I honestly don't know what to try next.
 
Hi people.

I am working on a project an am currently blocked. I created an arraylist with the info I want displayed in the listview. I used an array adapter and put that in the setListAdapter. All this is done by the book.

However, when I run it, it goes through the whole program and then gives me an error that it can't find the list_item.xml resource. I check the path that it gave an it is there. I tried cleaning the project and restarting the computer but nothing works.

Does anyone have any ideas as to how I can fix this? I'd really appreciate the help.

Additional Info: I have been doing tests and it I learned that the program messes up when I use setListAdapter(value).

fyi: The variable value is what i get from the array adapter.

Hope this info is useful. I really need some help to solve this. I honestly don't know what to try next.


Code:
public class waFinalActivity extends ListActivity {
	static ArrayList<String> stations=new ArrayList<String>();
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getAvailableStations();
		
		
		ArrayAdapter<String> value=new ArrayAdapter<String>(this,R.layout.list_item,stations);
		System.out.println("test1");
		setListAdapter(value);
		System.out.println("test2");
		ListView lv=getListView();
		lv.setAdapter(value);//<------------ gets stuck here
		lv.setTextFilterEnabled(true);
		System.out.println("test3: setting");
	}
	
	/*protected void onListItemClick(ListView lv, View v,int position, long id){
		super.onListItemClick(lv,v,position,id);
		String openStation=stations.get(position);
		try{
			Cla
		}
		catch(){
			
		}
	}*/
	
	/**********************************get station IDs***************************************/
	private void getAvailableStations() {
		AssetManager am=getAssets();
		InputStream s = null;
		try{
			s=am.open("fl_wx_index.xml");
			DocumentBuilderFactory dbFac=DocumentBuilderFactory.newInstance();
			DocumentBuilder db=dbFac.newDocumentBuilder();
			Document doc=db.parse(s);
			doc.getDocumentElement().normalize();
			
			NodeList nL=doc.getElementsByTagName("station");

			for(int i=0;i<nL.getLength();i++){
				Node n=nL.item(i);
				if(n.getNodeType()==Node.ELEMENT_NODE){
					Element eElement=(Element)n;
					String value=getTagValue("station_id",eElement);
					stations.add(value);
				}
			}
			am.close();
		}
		catch(FileNotFoundException e){

		} catch (IOException e) {

			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally{
			try {
				s.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/*****************************************************************************************/
	private String getTagValue(String sTag, Element eElement) {
		NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
		Node nValue = (Node) nlList.item(0);
		return nValue.getNodeValue();
	}
}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones