Android 简单布局器不更新视图
我在这上面花了太多时间。最初,我使用一个简单的“onAction”方法和一个XMLOnClick语句来控制位于ExpandableListView内部的按钮。我想最好使用充气,这样我可以在运行时更好地控制按钮。你可以看到前面的帖子 这是我最近的一次尝试。我没有得到任何异常或错误,它只是不做任何事情。我知道这个版本有点牵强,所以如果你有时间,在建议我可能已经尝试过的东西之前,请查看上面的链接,了解我的其他尝试 BrowseActivity.classAndroid 简单布局器不更新视图,android,expandablelistview,layout-inflater,Android,Expandablelistview,Layout Inflater,我在这上面花了太多时间。最初,我使用一个简单的“onAction”方法和一个XMLOnClick语句来控制位于ExpandableListView内部的按钮。我想最好使用充气,这样我可以在运行时更好地控制按钮。你可以看到前面的帖子 这是我最近的一次尝试。我没有得到任何异常或错误,它只是不做任何事情。我知道这个版本有点牵强,所以如果你有时间,在建议我可能已经尝试过的东西之前,请查看上面的链接,了解我的其他尝试 BrowseActivity.class public void onCreate(Bu
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>
任何帮助或建议都将不胜感激 尝试初始化布局充气器
LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
你想做什么,你能告诉我吗?简而言之,我没有明白你的意思。在上面的例子中,我正在尝试更改TextView(位于不同布局中)的颜色。如果我能让这个工作,我想控制一个可扩展列表中的其他项目。例如图像按钮、文本视图、背景色等。基本上,我希望在运行时控制驻留在其他布局中的视图。如果要将该布局膨胀为一行
ExpandableListView
,则应使用适配器自定义行。看一看子类化过去我曾尝试使用BaseExpandableListAdapter,但放弃了我的代码,因为我觉得从sql数据库中提取信息并在显示之前将其存储在数组中是不好的。这样可以吗?