FrameLayout addview 之后没有显示出来的问题??

java_wliang 2014-03-16 09:48:54

<com.egov.view.MyScrollLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/llayout" >

<com.egov.view.MyFrame
android:id="@+id/myFrame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white" >

<include layout="@layout/choose"/>
</com.egov.view.MyFrame>


然后在choose中有一个按钮,点击之后监听如下:



public OnClickListener chooseOnClickListener = new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("TOTO", "Start Listener");

Log.i("TOTO", "Start 1");
myFrame = (MyFrame)findViewById(R.id.myFrame);
Log.i("TOTO", "Start 2");
myFrame.removeAllViews();
Log.i("TOTO", "Start 3");

LinearLayout myLinearLayout = (LinearLayout)inflater.inflate(R.layout.mylistview, null);
FrameLayout.LayoutParams viewParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// ListView myListView = (ListView)myLinearLayout.findViewById(R.id.my)
Log.i("TOTO", "Start 4");

recordListView = (ListView) myLinearLayout.findViewById(R.id.recordListView);
myFrame.addView(myLinearLayout);
Log.i("TOTO", "Start 5");
Button btnButton = new Button(MainTOTO.this);
btnButton.setText("Test");
myFrame.addView(btnButton, viewParams);

problems = new ProblemsLVAdapter(MainTOTO.this);
problems.notifyDataSetChanged();

// setContentView(R.layout.activity_main);

recordListView.setAdapter(problems);
recordListView.setCacheColorHint(0);

recordListView.setOnItemClickListener(onItemClickListener);
}




然后切换的listview 如下:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ListView
android:id="@+id/recordListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:divider="@drawable/reader_item_divider"
android:listSelector="@drawable/item_selector" >
</ListView>

</LinearLayout>




但是, 点击之后,当前的按钮不见了, 但是没有出现监听之后的信息,而是空白的?



...全文
910 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
java_wliang 2014-03-17
  • 打赏
  • 举报
回复
没有人知道吗????????
java_wliang 2014-03-16
  • 打赏
  • 举报
回复
我是想实现功能呢个如下:; 在子布局中 有一个按钮 按钮监听之后实现 切换画面,出现另外的画面 但是另外的画面没有出来???

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧