- 給LinearLayout添加滾動條
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="[http://schemas.android.com/apk/res/android](http://schemas.android.com/apk/res/android)"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:fadingEdge="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<scrollView>下只能有一個子控件
- Activity之間對象傳遞
1.所傳的對象 實(shí)現(xiàn)接口 Serializable:
<pre>
public class Person implements Serializable {
</pre>
2.傳遞對象的原始頁面調(diào)用intent.putExtra()即可:
<pre>
Intent intent = new Intent();
Person obj = new Person(wg_name.getText().toString(),wg_age.getText().toString());
intent.putExtra("Person", obj);
intent.setClass(Demo_trans_objectActivity.this, OtherActivity.class);
startActivity(intent);
</pre>
3.接收對象的界面使用getIntent().getSerializableExtra()獲取對象:
<pre>
Person p = (Person) getIntent().getSerializableExtra("Person");
((TextView)findViewById(R.id.name)).setText(p.name);
((TextView)findViewById(R.id.age)).setText(p.age);
</pre>
給Layout設(shè)置邊框
<pre>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFFFFF" />
<stroke
android:width="0.01dp"
android:color="#FFFFFF" />
<padding
android:bottom="1dp"
android:left="0.5dp"
android:right="0.5dp"
android:top="0dp" />
</shape>
</pre>
然后給layout指定background屬性就可以通過控制臺將sqlite數(shù)據(jù)庫文件導(dǎo)出
<pre>
adb pull /data/data/com.yourproject/databases/testdatabase.db d:\shownearby.db
</pre>EditText添加監(jiān)聽
監(jiān)聽EditText的變化
<pre>
et.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
tv.setText("還能輸入"+Rest_Length+"個字");
}
@Override
public void afterTextChanged(Editable s) {
tv.setText("還能輸入"+Rest_Length+"個字");
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(Rest_Length>0){
Rest_Length = MAX_LENGTH - et.getText().length();
}
}
});
</pre>清空listview(添加了listAdapter)的方法
- listView.setAdapter(null);
- listAdapter.clear();
listAdapter.notifyDataSetChanged() ;