为什么我一运行程序 就显示 很抱歉,Demo已停止运行
我是用手机测试的
难道是手机问题
是怎回事 啊?
我是用手机测试的
难道是手机问题
是怎回事 啊?
2015-06-06
这个是MainActivity.java
package com.imooc.demo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;
public class MainActivity extends Activity {
private AutoCompleteTextView acTextView;
private MultiAutoCompleteTextView macTextView;
private String[] res={"李浩","李浩1","李浩2","李浩3","李浩4"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
acTextView=(AutoCompleteTextView)findViewById(R.id.
autoCompleteTextView1);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,res);
acTextView.setAdapter(adapter);
macTextView=(MultiAutoCompleteTextView)findViewById(R.
id.multiAutoCompleteTextView1);
macTextView.setAdapter(adapter);
macTextView.setTokenizer(new
MultiAutoCompleteTextView.CommaTokenizer());
}
}
这个是activity.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="2"
android:hint="@string/hello_world" />
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="2"
android:hint="@string/action_setting" />
</LinearLayout>
这个是String.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Demo</string>
<string name="hello_world">请输入你要搜索的关键字</string>
<string name="action_setting">请输入你的联系人</string>
</resources>
你能调试一下吗?
举报