Android 常用代码

时间:2023-03-09 16:12:09
Android 常用代码

1.单元测试

然而可以直接建立单元测试

<uses-library android:name="android.test.runner"/>
放在application里

<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.pccw" android:label="aaa"/>
需要手动修改包名

2.AutoCompleteTextView

private static final String[] autoStr=new String[]    {"a","abc","abcd","abcde"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ArrayAdapter adapter= new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line ,autoStr);
        AutoCompleteTextView autocompletetextview= (AutoCompleteTextView) this.findViewById(R.id.Auto);
        autocompletetextview.setAdapter(adapter);
    }