我刚刚从我的应用程序中删除了medialytics api,因为我发现它浪费时间,而不是其他任何问题。
问题是,现在我的应用程序在logcat
中启动上面的消息时崩溃了以下是我的主要活动的源代码
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);
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);
}
}
});
}
}
这是布局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>
任何人都可以发现问题,因为对于我的生活我不能。
答案 0 :(得分:2)
首先,让ListView
拥有android:layout_height="wrap_content"
非常糟糕。这将使ListView
衡量每个孩子。
其次,检查您的AndroidManifest
。从你的代码中你应该在你的清单中有几个活动。
"Area", "Density", "Distance", "Energy", "Pressure", "Temperature", "Velocity", "Volume", "Weight"
。
答案 1 :(得分:1)
对不起。真是个愚蠢的错误
我有
public abstract class
而不是
public class
抱歉=(