【发布时间】:2014-09-09 10:05:52
【问题描述】:
我在项目中有片段 我想创建 Listview 但我不能: 这个代码怎么改?
public class Menu extends Fragment implements OnClickListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// TODO Auto-generated method stub
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.menu, container, false);
//Button ButtonF1= (Button) rootView.findViewById(R.id.buttonF1);
//ButtonF1.setOnClickListener(this);
return rootView;
};
}
还有我的 Xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
【问题讨论】:
-
试试this
-
我有扩展片段
-
@sajjadYosefi :不清楚你在问什么。此外,创建一个名为
Menu的类也是一个坏主意,因为 Android 也有一个具有该名称的类 - 你可能会遇到冲突。最后,ListView的代码在哪里?你还没有展示它。
标签: android listview android-fragments