Java::::-android.widget.LinearLayout cannot be cast to android.widget.TextView« Back to Previous Page

package com.androidhive.androidlistview;

import nm.nm;
import noti.noti;
import chairman.chairman;
import cm.cm;
import cmembership.cmem;
import lom.lom;
import ma.ma;
import mb.mb;
import mpb.mpb;
import msm.msm;
import mwb.choosemonth;
import pl.pl;
import plfma.plfma;

import pwl.pwl;
import qc.qc;
import rdecl.rdecl;
import secretarygeneral.secretarygeneral;
import sql.sql;
import swl.swl;
import ul.ul;
import verbatim.verbatim;
import wml.wml;
import dailysynopsis.dailysynopsis;
import datewisecommittemeetings.datewisecommittemeetings;
import djc.djc;
import dychairman.dychairman;
import committewisemeetings.committewisemeetings;
import bulletini.bulletini;
import bulletinii.bulletinii;
import businessfeeds.businessfeeds;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class AndroidListViewActivity extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // storing string resources into Array
        String[] choices = getResources().getStringArray(R.array.choices);
        
        // Binding Array to ListAdapter
        this.setListAdapter(new ArrayAdapter(this, R.layout.list_item, R.id.label, choices));
        
        ListView lv = getListView();

        // listening to single list item on click
        lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView parent, View view,
              int position, long id) {
        	  // selected item 
        	  
        	  String product = ((TextView) view).getText().toString();
        	  // Launching new Activity on selecting single List Item
        	  if (product.equals("Bulletin-I")) {
			  Intent i = new Intent(getApplicationContext(), bulletini.class);
        	  // sending data to new activity
        	  i.putExtra("product", product);
        	  startActivity(i);
        	  }
And this is the XML file-
[NO-CODE-HERE]
It just keeps showing me the following error-
08-11 10:35:21.531: E/AndroidRuntime(792): FATAL EXCEPTION: main
08-11 10:35:21.531: E/AndroidRuntime(792): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
08-11 10:35:21.531: E/AndroidRuntime(792): 	at com.androidhive.androidlistview.AndroidListViewActivity$1.onItemClick(AndroidListViewActivity.java:63)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.widget.AdapterView.performItemClick(AdapterView.java:298)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.widget.AbsListView$1.run(AbsListView.java:3423)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.os.Handler.handleCallback(Handler.java:725)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.os.Handler.dispatchMessage(Handler.java:92)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.os.Looper.loop(Looper.java:137)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at java.lang.reflect.Method.invokeNative(Native Method)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at java.lang.reflect.Method.invoke(Method.java:511)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-11 10:35:21.531: E/AndroidRuntime(792): 	at dalvik.system.NativeStart.main(Native Method)
Posted by shadeslayer199318 (Questions:1, Answers:0)
Asked on August 11, 2013 11:51 am
Category: Android
0

Please post your XML layout file and wrap it in the <pre>

Posted by itcuties (Questions:2, Answers:18)
Answered On August 11, 2013 12:09 pm #
No account?



It's FREE!

Like what you have found?


... and keep us going