我有一个ViewPager
使用片段。正在使用ListView
默认设置,但是如何使用自定义ListView
(字体大小+图像)?
到目前为止我的代码:
public class Page2Fragment extends Fragment {
Button btnWrite;
public String ptext="..PAGE 2..";
private String arry[] = { "Tofeeq", "Ahmad", "Fragment", "Example",
"Tofeeq", "Ahmad", "Fragment", "Example" };
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
// fragment not when container null
if (container == null) {
return null;
}
// inflate view from layout
View view = (LinearLayout)inflater.inflate(R.layout.page2,container,false);
// update text
TextView tv = (TextView) view.findViewById(R.id.tvText2);
tv.setText(ptext);
ListView listView = (ListView) view.findViewById(R.id.listView1);
ArrayAdapter<String> array = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
for (String str : arry)
array.add(str);
listView.setAdapter(array);
return view;
}
// set text helper function
public void setText(String item) {
TextView view = (TextView) getView().findViewById(R.id.tvText2);
view.setText(item);
}
}