这是我得到的错误:
11-01 18:40:55.535:D / dalvikvm(1636):没有迟到的CheckJNI (已经开启)11-01 18:40:55.575:D / AndroidRuntime(1636):关闭 VM 11-01 18:40:55.575:W / dalvikvm(1636):threadid = 1:线程退出 未捕获的异常(group = 0xb0d9ece8)11-01 18:40:55.575: E / AndroidRuntime(1636):致命异常:主11-01 18:40:55.575: E / AndroidRuntime(1636):处理:com.example.inflate,PID:1636 11-01 18:40:55.575:E / AndroidRuntime(1636):java.lang.RuntimeException: 无法开始活动 ComponentInfo {com.example.inflate / com.example.inflate.MainActivity}: android.util.AndroidRuntimeException:你无法组合滑动 解雇和行动吧。 11-01 18:40:55.575: E / AndroidRuntime(1636):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197) 11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258) 11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.ActivityThread.access $ 800(ActivityThread.java:138)11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1209) 11-01 18:40:55.575:E / AndroidRuntime(1636):at android.os.Handler.dispatchMessage(Handler.java:102)11-01 18:40:55.575:E / AndroidRuntime(1636):at android.os.Looper.loop(Looper.java:136)11-01 18:40:55.575: E / AndroidRuntime(1636):at android.app.ActivityThread.main(ActivityThread.java:5026)11-01 18:40:55.575:E / AndroidRuntime(1636):at java.lang.reflect.Method.invokeNative(Native Method)11-01 18:40:55.575:E / AndroidRuntime(1636):at java.lang.reflect.Method.invoke(Method.java:515)11-01 18:40:55.575: E / AndroidRuntime(1636):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:777) 11-01 18:40:55.575:E / AndroidRuntime(1636):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)11-01 18:40:55.575:E / AndroidRuntime(1636):at dalvik.system.NativeStart.main(Native Method)11-01 18:40:55.575: E / AndroidRuntime(1636):引起: android.util.AndroidRuntimeException:你无法组合滑动 解雇和行动吧。 11-01 18:40:55.575: E / AndroidRuntime(1636):at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275) 11-01 18:40:55.575:E / AndroidRuntime(1636):at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872) 11-01 18:40:55.575:E / AndroidRuntime(1636):at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129) 11-01 18:40:55.575:E / AndroidRuntime(1636):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303) 11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.Activity.setContentView(Activity.java:1930)11-01 18:40:55.575:E / AndroidRuntime(1636):at com.example.inflate.MainActivity.onCreate(MainActivity.java:25)11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.Activity.performCreate(Activity.java:5242)11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 11-01 18:40:55.575:E / AndroidRuntime(1636):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
以下是我的代码的MainActivity:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listview =(ListView) findViewById(R.id.listView);
CustomAdapter adapter= new CustomAdapter(MainActivity.this);
listview.setAdapter(adapter);
}
public class CustomAdapter extends BaseAdapter {
private String[] str_mediumtext = { "INDIA", "UK","SINGAPORE", "THAILAND", };
private String[] str_smalltext = { "aaaaaaaaaaaa", "agfffffffff","gfdnvmnvnjkfdndnmcnv", "chfvdkfhfkdhfjfh"};
private Integer[] int_images = { R.drawable.images, R.drawable.dessert,R.drawable.pilaurice,R.drawable.prawn};
//private boolean [] bool_check = { true, true, false, true};
private LayoutInflater layoutinflator;
public CustomAdapter (Context context) {
layoutinflator = LayoutInflater.from(context);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final Holder holder;
if(convertView != null) {
holder = new Holder();
//convertView = layoutinflator.inflate(R.layout.listview, Anull);
convertView = layoutinflator.inflate(R.layout.listview, parent, false);
holder.imageview = (ImageView)convertView.findViewById(R.id.imageView1);
holder.tvMedium = (TextView)convertView.findViewById(R.id.textView1);
holder.tvSmall = (TextView)convertView.findViewById(R.id.textView2);
holder.checkbox = (CheckBox)convertView.findViewById(R.id.checkBox1);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
holder.tvMedium.setText(str_mediumtext[position]);
holder.tvSmall.setText(str_smalltext[position]);
holder.imageview.setImageResource(int_images[position]);
return convertView;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return str_mediumtext.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
} }
class Holder {
ImageView imageview;
TextView tvMedium, tvSmall;
CheckBox checkbox;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
我正在致命的例外。请帮我解决这个问题
答案 0 :(得分:0)
您可能正在尝试编译Wear设备,或尝试在4.4W API仿真器上运行它。 将targetSdk版本设置为19,并在4.4(不带W)仿真器/设备上尝试。