1

私は一晩中このエラーを見つけて修正しようとしました。エラーの正確な原因はわかりませんが、このクラスを実行しようとするとアプリがクラッシュします。ListView または配列と関係があるのではないかと思います。

私のJavaファイル:

package com.example.ispoke;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class AustralianAnimalsMenu extends ListActivity{

String AusAnimalItm[] = {"Aus Animal 1", "Aus Animal 2", "Aus Animal 3", "Aus      Animal 4", "Aus Animal 5"}; 

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_australiananimalsmenu);

    setListAdapter(new ArrayAdapter<String>(AustralianAnimalsMenu.this, android.R.layout.activity_list_item, AusAnimalItm));        
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub

    super.onListItemClick(l, v, position, id);
    String selection = AusAnimalItm[position];
    try{            
    Class<?> ourClass =  Class.forName("com.example.ispoke." + selection);
    Intent ourIntent = new Intent(AustralianAnimalsMenu.this, ourClass);
    startActivity(ourIntent);       
    }catch(ClassNotFoundException ell){
        ell.printStackTrace();
    }
}

}

私のxmlファイル:

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

        <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView1"
        android:text="Done"
        android:textSize="10sp" />

        <TextView
        android:id="@+id/textView1"
        android:layout_width="271dp"
        android:layout_height="31dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:gravity="center_horizontal"
        android:text="Australian Animals"
        android:textSize="25sp" />
</RelativeLayout>

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="369dp"
    android:layout_weight="1.06" >
</ListView>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="34dp"
    android:gravity="bottom"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="Edit"
        android:textSize="15sp" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Delete"
        android:textSize="15sp" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="+"
        android:textSize="20sp" />
</RelativeLayout>

エラー スタック:

Thread [<1> main] (Suspended (exception IllegalStateException)) 
<VM does not provide monitor information>   
ListView.layoutChildren() line: 1662    
ListView(AbsListView).onLayout(boolean, int, int, int, int) line: 1147  
ListView(View).layout(int, int, int, int) line: 7035    
LinearLayout.setChildFrame(View, int, int, int, int) line: 1249 
LinearLayout.layoutVertical() line: 1125    
LinearLayout.onLayout(boolean, int, int, int, int) line: 1042   
LinearLayout(View).layout(int, int, int, int) line: 7035    
FrameLayout.onLayout(boolean, int, int, int, int) line: 333 
FrameLayout(View).layout(int, int, int, int) line: 7035 
LinearLayout.setChildFrame(View, int, int, int, int) line: 1249 
LinearLayout.layoutVertical() line: 1125    
LinearLayout.onLayout(boolean, int, int, int, int) line: 1042   
LinearLayout(View).layout(int, int, int, int) line: 7035    
PhoneWindow$DecorView(FrameLayout).onLayout(boolean, int, int, int, int) line: 333  
PhoneWindow$DecorView(View).layout(int, int, int, int) line: 7035   
ViewRoot.performTraversals() line: 1045 
ViewRoot.handleMessage(Message) line: 1727  
ViewRoot(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 123 
ActivityThread.main(String[]) line: 4627    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line:  
    not available [native method]
    Method.invoke(Object, Object...) line: 521

    ZygoteInit$MethodAndArgsCaller.run() line: 868  
    ZygoteInit.main(String[]) line: 626 
    NativeStart.main(String[]) line: not available [native method]  
4

0 に答える 0