搜索
您的当前位置:首页正文

android 日常(一)

来源:二三娱乐
  • 给LinearLayout添加滚动条
<?xml version="1.0" encoding="utf-8"?> 
<ScrollView      
  
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.所传的对象 实现接口 Serializable:
    <pre>
    public class Person implements Serializable {
    </pre>
    2.传递对象的原始页面调用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>

  • 清空listview(添加了listAdapter)的方法

  1. listView.setAdapter(null);
  2. listAdapter.clear();
    listAdapter.notifyDataSetChanged() ;
Top