onActivityforresult 和 Scrollview滚动

来源:互联网 发布:js ui隐藏不安全 编辑:程序博客网 时间:2024/06/05 05:24


// 开启activity

Intent intent = new Intent(this, ActivityGiftMoneyDetail.class);intent.putExtra("isEmpty", isEmpty);intent.putExtra("id", id);int requestCode = 100;startActivityForResult(intent, requestCode);
@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {    super.onActivityResult(requestCode, resultCode, data);    if (resultCode == 200) {        // 谁在发红包返回        refreshList(0, true);    }}

// 返回原来的activity

//常规点击返回
onclick{
     ..........
     setResult(200,intent);
     finish();
}
// 点击返回键返回
@Overridepublic void onBackPressed() {    setResult(200, getIntent()); //复写 onBackPressed后首先调用setResult    super.onBackPressed();}@Overridepublic void onBackKeyDown() {    setResult(200, getIntent());    super.onBackKeyDown();}


//给一个布局动态添加view ,并可以滑动
//最外层固定高度  
//scrollview :子元素只能有一个喔
//scrollview子元素添加 item即可  // item_parent.addView( ...);
<LinearLayout    android:layout_width="wrap_content"    android:layout_height="match_parent"    android:layout_weight="1"    android:background="@color/white"    android:orientation="vertical">    <ScrollView        android:layout_width="match_parent"        android:layout_height="match_parent">        <LinearLayout            android:id="@+id/item_parent"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:orientation="vertical">        </LinearLayout>    </ScrollView></LinearLayout>










0 0
原创粉丝点击