程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> onclick-android-textview中點擊崩潰

onclick-android-textview中點擊崩潰

編輯:編程綜合問答
android-textview中點擊崩潰

extend baseActivity,但是textview 中一個簡單的onClick總是崩潰。

TextView labelName_view = (TextView) findViewById(R.id.labelName);
labelName_view.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        // animazione automatica al click
        LinearLayout contenitore_cibo_l=(LinearLayout) findViewById(R.id.bottom_container);
        LayoutParams lp = (LayoutParams) contenitore_cibo_l.getLayoutParams();
        System.out.println(lp.topMargin);
        //contenitore_cibo_l.startAnimation(makeAnimation_ordini(400, 25));
    }
});

崩潰於:

05-27 12:30:22.722: E/AndroidRuntime(2932): FATAL EXCEPTION: main
05-27 12:30:22.722: E/AndroidRuntime(2932): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.app.ActionBar$LayoutParams
05-27 12:30:22.722: E/AndroidRuntime(2932):     at com.web_pos.android.OrderActivity$4.onClick(OrderActivity.java:296)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.view.View.performClick(View.java:3511)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.view.View$PerformClick.run(View.java:14105)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.os.Handler.handleCallback(Handler.java:605)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.os.Looper.loop(Looper.java:137)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at java.lang.reflect.Method.invokeNative(Native Method)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at java.lang.reflect.Method.invoke(Method.java:511)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-27 12:30:22.722: E/AndroidRuntime(2932):     at dalvik.system.NativeStart.main(Native Method)

最佳回答:


類型轉換異常,你把RelativeLayout 強轉成了ActionBar

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved