开发者

Runtime Exception: Unable to instantiate activity component info

I have just stripped out the medialytics api from my app because i found it a waste of time and more of a problem than anything else.

Problem is, now my app crashes on start up with the above message in the logcat

Here is the source code for my main activity

public abstract class Converter extends Activity {
    private ListView lv1;
    private String lv_arr[] = {"Area", "Density", "Distance", "Energy",
            "Pressure", "Temperature", "Velocity", "Volume", "Weight"};

    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);

        AdView adView = (AdView)findViewById(R.id.ad);
        adView.requestFreshAd();

        AdManager.setTestDevices( new String[] {
            AdManager.TEST_EMULATOR,
                "E83D20734F72FB3108F104ABC0FFC738", 
        } );


        lv1 = (ListView)findViewById(R.id.MainList);
        lv1.setAdapter(new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, v_arr));
            lv1.setOnItemClickListener(new OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                if ("Area".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this, Area.class);
                    startActivity(i);

                }if ("Density".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Density.class);
              开发者_C百科      startActivity(i);

                }if ("Distance".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Distance.class);
                    startActivity(i);

                }if ("Energy".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Energy.class);
                    startActivity(i);     

                }if ("Pressure".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Pressure.class);
                    startActivity(i);

                }if ("Temperature".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Temperature2.class);
                    startActivity(i);

                }if ("Velocity".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Velocity.class);
                    startActivity(i);

                }if ("Volume".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Volume.class);
                    startActivity(i);

                }if ("Weight".equals(lv_arr[arg2])){
                    Intent i = new Intent(Converter.this,Weight.class);
                    startActivity(i);
                }
            }
        });
    }
}

And here is the layout xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/app.android.converter"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.admob.android.ads.AdView
        android:id="@+id/ad"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        myapp:backgroundColor="#000000"
        myapp:primaryTextColor="#FFFFFF"
        myapp:secondaryTextColor="#CCCCCC" />
    <TextView android:id="@+id/MenuText" 
        android:text="Pick a Category to Begin" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_below="@id/ad"
        android:textStyle="bold" /> 
    <ListView
        android:id="@+id/MainList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/MenuText" />
</RelativeLayout>

Can anyone spot the problem because for the life of me I cannot.


First of all, it's very bad to make a ListView have android:layout_height="wrap_content". This will make the ListView measure every child.

Secondly, check your AndroidManifest. From your code you should have in your manifest several activities.

"Area", "Density", "Distance", "Energy", "Pressure", "Temperature", "Velocity", "Volume", "Weight".


sorry. really really stupid mistake

i had

public abstract class

instead of

public class

sorry =(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜