表视图给出错误低于API级别11

时间:2013-05-06 07:22:13

标签: android android-tablelayout

我正在尝试生成一个有问题的动态表它在API>之上正常工作11但它显示了一些像这样的错误

05-06 12:35:30.303: E/AndroidRuntime(386): FATAL EXCEPTION: main
05-06 12:35:30.303: E/AndroidRuntime(386): java.lang.NoClassDefFoundError: android.app.ActionBar$LayoutParams
05-06 12:35:30.303: E/AndroidRuntime(386):  at com.ica.icacounselor.Follow_ups_list_third_level.populateTable(Follow_ups_list_third_level.java:105)
05-06 12:35:30.303: E/AndroidRuntime(386):  at com.ica.icacounselor.Follow_ups_list_third_level.onCreate(Follow_ups_list_third_level.java:65)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.os.Looper.loop(Looper.java:123)
05-06 12:35:30.303: E/AndroidRuntime(386):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-06 12:35:30.303: E/AndroidRuntime(386):  at java.lang.reflect.Method.invokeNative(Native Method)
05-06 12:35:30.303: E/AndroidRuntime(386):  at java.lang.reflect.Method.invoke(Method.java:507)
05-06 12:35:30.303: E/AndroidRuntime(386):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-06 12:35:30.303: E/AndroidRuntime(386):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-06 12:35:30.303: E/AndroidRuntime(386):  at dalvik.system.NativeStart.main(Native Method)

我的代码如下

    //--------------------------------------------------------------------------------------------------
    // Creating Table Header
    //--------------------------------------------------------------------------------------------------

    TableRow followup_tr_head = new TableRow(this);
    followup_tr_head.setId(10);
    followup_tr_head.setBackgroundResource(R.drawable.list_header);
    followup_tr_head.setLayoutParams(new LayoutParams(
            LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));


    final TextView time_name_title = new TextView(this);
    time_name_title.setId(20);
    time_name_title.setText("Time");
    time_name_title.setTextColor(Color.WHITE);
    time_name_title.setPadding(5,5,5,5);
    followup_tr_head.addView(time_name_title);// add the column to the table row here
    time_name_title.setTextSize(12);    

    final TextView student_name_title = new TextView(this);
    student_name_title.setId(20);
    student_name_title.setText("Student Name");
    student_name_title.setTextColor(Color.WHITE);
    student_name_title.setPadding(5,5,5,5);
    followup_tr_head.addView(student_name_title);// add the column to the table row here
    student_name_title.setTextSize(12);    

3 个答案:

答案 0 :(得分:2)

ActionBar在API 11中提供。您不能在较低的API级别中使用它。

答案 1 :(得分:1)

是的,您不能在API级别11下使用ActionBar。 要在较低的api级别使用操作栏,请使用ActionBarSherlock

答案 2 :(得分:0)

我导入了导入android.app.ActionBar.LayoutParams;

我应该导入android.widget.TableRow.LayoutParams;