0

I have been working for a few days to have arrays of data be displayed into arrays of TextView. Preferrably I am wanting up to 10 rows of TextViews with 4 columns.

Currently I have the following .java file and it is thorwing a fatal error:

public class DebtList extends Activity {
Integer trigger = 5;
Double totalDebt = 0.00;

//TextView dispTotalDebt = (TextView)findViewById(R.id.dispTotalDebt); 

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.debtlist);

    Bundle extras = getIntent().getExtras();

    String[] debtNames = new String[10];
    Double[] debtAmount = new Double[10];
    Double[] debtRate = new Double[10];
    Double[] debtTerm = new Double[10];

    debtNames[trigger] = extras.getString("nickname");

    View linearLayout =  findViewById(R.id.debtlist);
    Integer stopper = trigger+1;

    for(int i=0; i < stopper; i++)
    {
        TextView value = new TextView(this);
        value.setText("test" + i); //debtNames[i] later
        value.setId(i);
        value.setTextSize(50);
        value.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        ((LinearLayout) linearLayout).addView(value);

    }

    trigger++;
}
}

Here is the .xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/debtlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/totalDebt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Total Debt:" />
<TextView
    android:id="@+id/dispTotalDebt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="" />

</LinearLayout>

and lastly, here is the logcat for when I run this.

10-13 02:16:16.785: W/dalvikvm(898): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-13 02:16:16.795: E/AndroidRuntime(898): FATAL EXCEPTION: main
10-13 02:16:16.795: E/AndroidRuntime(898): java.lang.NoClassDefFoundError: android.app.ActionBar$LayoutParams
10-13 02:16:16.795: E/AndroidRuntime(898):  at biz.midl.debttracking.DebtList.onCreate(DebtList.java:42)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.os.Looper.loop(Looper.java:123)
10-13 02:16:16.795: E/AndroidRuntime(898):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-13 02:16:16.795: E/AndroidRuntime(898):  at java.lang.reflect.Method.invokeNative(Native Method)
10-13 02:16:16.795: E/AndroidRuntime(898):  at java.lang.reflect.Method.invoke(Method.java:507)
10-13 02:16:16.795: E/AndroidRuntime(898):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-13 02:16:16.795: E/AndroidRuntime(898):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-13 02:16:16.795: E/AndroidRuntime(898):  at dalvik.system.NativeStart.main(Native Method)

End result, I want a person to be able to input debt information on Activity (DebtInput.java) which has an intent upon the "add" button being selected. The intent will bring the data tot his activity for display in ADDITION to the old data.

2
  • android.app.ActionBar is only present in API level 11. Whatever you're deploying to does not have that class. What are you deploying to? Commented Oct 13, 2013 at 2:36
  • level 10 - I'm trying to change my Emulator to 11 but it's giving me problems, I'll post when I have an update Commented Oct 13, 2013 at 2:57

2 Answers 2

2

the ActionBar is presented in API 11. You can't use it in lower API levels.

See this solution, it may help.

Table view giving error below API level 11

Sign up to request clarification or add additional context in comments.

1 Comment

upon upgrading the API to 12 it functions, thank you Justin and Bette for the notification of the error!
0

I don't see your import statements, but you probably get them wrong.

Instead of import ...ViewGroup.LayoutParams (or LinearLayout.LayoutParams) you may have
import ActionBar.LayoutParams which wouldn't work with pre API 11 (and this is just wrong, because ActionBar.LayoutParams is incompatible with LinearLayout.LayoutParams). By changing that you should get it working with any API, even API 1!

P.S To change target API, go to Project / Properties / Android and pick up target, provided you have corresponding API installed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.