English 中文(简体)
造成java.ang.ClassCastException:android.widget. 案文
原标题:Textview causing java.lang.ClassCastException: android.widget.TextView

我有三点文字调查,并用点击它们,但当我点击其中任何一种情况,即它们造成部队应用中的错误。 i)还尝试修改女方言表,然后进行清理项目,并且实施项目时仍然不会消除错误。

我的XML守则

一份案文概述

<LinearLayout
        android:id="@+id/LL_fb" 
        android:layout_width="180px"
        android:layout_height="27px"
        android:layout_above="@+id/txt_msg_regs"
        android:layout_alignLeft="@+id/LL_signup"
        android:layout_marginBottom="25dp"
        android:background="@drawable/facebook" >        
    <TextView
        android:id="@+id/btn_txt_fb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Connect with facebook"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="23dp"
        android:layout_marginTop="1dp"
        android:clickable="true"
        android:textColor="#FFFFFF" />
    </LinearLayout>

第二份案文概述

<LinearLayout 
        android:id="@+id/LL_signup"
        android:layout_width="180px"
        android:layout_height="29px"
        android:layout_above="@+id/textView1"
        android:layout_alignLeft="@+id/LL_login"
        android:background="@drawable/lmyic_signup">

    <TextView
        android:id="@+id/btn_txt_sinup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="signup with email"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="1dp"
        android:clickable="true"
        android:textColor="#FFFFFF" />

    </LinearLayout>

页: 1

 <LinearLayout 
            android:id="@+id/LL_login"
            android:layout_width="180px"
                android:layout_height="29px"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="69dp"
                android:background="@drawable/lmyic_login">
        <TextView
            android:id="@+id/btn_txt_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Log in"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="1dp"
            android:textColor="#FFFFFF" 
            android:clickable="true"/> 
        </LinearLayout>

这是我的roid。 这一名词也正确,一经核实。

TextView img_login;
img_login = (TextView)findViewById(R.id.btn_txt_login);
 img_login.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                if(v.getId() == img_login.getId())
                {
                Intent i_lin = new Intent(LockmeifyoucanActivity.this,lmiyc_login.class);
                startActivity(i_lin);
                }                   
            }
        });

请让我说,这是错误的。 如果需要标识,那么我会问我。

问题回答

请张贴完整的XMl,以便我们能够看到这块 b子。

它认为是纽芬兰的,因为“定论ById (R.id.btn_txt_login);”如果“btn_txt_login” id不是在xml中的话,就会退回无效。

you have some problem with textview in lmiyc_login activity.in lmiyc_login corrent line number 46 which maybe:

TextView txtview;
txtview = (TextView)yourlayout.findViewById(R.id.txtviewid);
findViewById(R.id.btn_txt_login);

这是否真的是一种书面意见,或者你是否在你的布局中也有一个布塔顿? 我认为,你再次试图将布托托带入案文。

Wrong resource ID...

img_login = (TextView)findViewById(R.id.btn_txt_login);

根据您的XML,

img_login = (TextView)findViewById(R.id.txt_login);

etc..

change ur code with this

TextView img_login;
 img_login = (TextView)findViewById(R.id.txt_login);
   img_login.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            if(v.getId().equals(img_login.getId()))
            {
            Intent i_lin = new Intent(LockmeifyoucanActivity.this,lmiyc_login.class);
            startActivity(i_lin);
            }                   
        }
    });

为了迅速解决这一错误,在以下几个方面设定了一个突破点:

View view = findViewById(R.id.btn_txt_login);

然后,见关于地方表格的表格,参考gen/R.java.

这些路线为42-48条

 setContentView(R.layout.lmyic_login_page);                 
  txtBack = (TextView)findViewById(R.id.ImgViewTxtBack);          txtBack.setTypeface(null,Typeface.BOLD);
   iv_login = (ImageView)findViewById(R.id.Txtlogin);
   iv_login.setOnClickListener(this);
   iv_sign_up = (ImageView)findViewById(R.id.TxtSignup);

I think problem is with iv_login = (ImageView)findViewById(R.id.Txtlogin); – Dheeresh Singh 1 min ago edit because this is 46 line and it should be textview and you are castin it in Imageview – Dheeresh Singh just now edit

如果你重复了“Id”资源,那就会扔下阶级广播。 因此,确保在整个项目期间不会有重复内容。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签