简单的 LayoutInflater 不更新视图
我在这上面花费了太多的时间。最初,我使用一个简单的“onAction”方法与 XML onclick 语句并行来控制位于 ExpandableListView 内部的按钮。我认为使用通货膨胀会很好,这样我就可以在运行时更好地控制按钮。 查看之前的帖子
您可以在此处 是我的最新尝试。我没有收到任何异常或错误,它只是什么也不做。我知道这个版本有点牵强,所以如果您有时间,请先查看上面的链接,了解我的其他一些尝试,然后再建议我可能已经尝试过的东西!
BrowseActivity.class
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browse);
ViewGroup parent = (ViewGroup) findViewById(R.id.expandLinLayout);
ExpandableListView browseView = (ExpandableListView) findViewById(android.R.id.list);
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.row, parent);
LinearLayout linLay = (LinearLayout) view
.findViewById(R.id.LinearLayout1);
TextView rowTxt = (TextView) view.findViewById(R.id.txtItem);
rowTxt.setTextColor(Color.CYAN);
.........
}
包含列表的 browse.xml 代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
android:id="@+id/expandLinLayout"
>
<ExpandableListView
android:id = "@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:groupIndicator="@drawable/my_group_statelist"
>
</ExpandableListView>
</LinearLayout>
最后是 row.xml 代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_gravity="center_vertical|right"
android:id="@+id/txtItem"
android:text="Item"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
></TextView>
</LinearLayout>
任何帮助或建议将不胜感激。
I have spent entirely too much time on this. Originally, I was using a simple "onAction" method in parallel with an XML onclick statement to control a button located inside of my ExpandableListView. I thought it would be nice to use inflation so I could have more control of the button during runtime. You can see an earlier post HERE
This is my latest attempt. I do not get any exceptions or errors, it just does nothing. I know this version is a little far fetched so if you have the time check out the link above for some of my other attempts before suggesting something I may have already tried!
BrowseActivity.class
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browse);
ViewGroup parent = (ViewGroup) findViewById(R.id.expandLinLayout);
ExpandableListView browseView = (ExpandableListView) findViewById(android.R.id.list);
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.row, parent);
LinearLayout linLay = (LinearLayout) view
.findViewById(R.id.LinearLayout1);
TextView rowTxt = (TextView) view.findViewById(R.id.txtItem);
rowTxt.setTextColor(Color.CYAN);
.........
}
The browse.xml code that contains the list:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
android:id="@+id/expandLinLayout"
>
<ExpandableListView
android:id = "@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:groupIndicator="@drawable/my_group_statelist"
>
</ExpandableListView>
</LinearLayout>
And finally the row.xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_gravity="center_vertical|right"
android:id="@+id/txtItem"
android:text="Item"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
></TextView>
</LinearLayout>
Any help or suggestions would be MUCH appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个来初始化布局充气机
Try this to initialize layout inflater