-1
我正在创建我的第一个应用程序,我想在listview中创建动作。Android - 动作列表视图
我已经创建列表视图,但是当我点击的观点,即特定的图标应该降落到一个新的页面,在这里我可以在你的ListFragment
缩进Web视图
public class HomeFragment extends ListFragment {
// Array of strings storing country names
String[] title = new String[] {
"About Us",
"Attend class",
"Events",
"What's hot",
"Social Networks"
};
// Array of integers points to images stored in /res/drawable/
int[] img = new int[]{
R.drawable.about,
R.drawable.clas,
R.drawable.cale,
R.drawable.hot1,
R.drawable.socil,
};
// Array of strings to store currencies
String[] description = new String[]{
"Our Story",
"vlrn.in",
"Update Your Schedule",
"Need a Hot cake ? ",
"Connect with us",
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// Each row in the list stores country name, currency and flag
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<5;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("txt", "" + title[i]);
hm.put("cur","" + description[i]);
hm.put("flag", Integer.toString(img[i]));
aList.add(hm);
}
// Keys used in Hashmap
String[] from = { "flag","txt","cur" };
// Ids of views in listview_layout
int[] to = { R.id.flag,R.id.txt,R.id.cur};
// Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList, R.layout.fragment_home, from, to);
setListAdapter(adapter);
return super.onCreateView(inflater, container, savedInstanceState);
}
}