Android-listview与操作

Android-listview与操作,android,listview,onclicklistener,Android,Listview,Onclicklistener,我正在创建我的第一个应用程序,我想在listview中创建操作 我已经创建了listview,但当我从视图中单击特定图标时,它应该会进入一个新页面,在那里我可以缩进一个web视图 public class HomeFragment extends ListFragment { // Array of strings storing country names String[] title = new String[] { "About Us", "Attend

我正在创建我的第一个应用程序,我想在listview中创建操作

我已经创建了listview,但当我从视图中单击特定图标时,它应该会进入一个新页面,在那里我可以缩进一个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);     
}

}
公共类HomeFragment扩展了ListFragment{
//存储国家名称的字符串数组
字符串[]标题=新字符串[]{
“关于我们”,
“上课”,
“活动”,
“什么是热的”,
“社交网络”
};    
//整数数组指向存储在/res/drawable中的图像/
int[]img=新int[]{
R.drawable.about,
R.drawable.clas,
R.drawable.cale,
R.drawable.hot1,
R.drawable.socil,
};
//存储货币的字符串数组
字符串[]说明=新字符串[]{
“我们的故事”,
“vlrn.in”,
“更新您的日程安排”,
“需要热蛋糕吗?”,
“与我们联系”,
};
@凌驾
创建视图上的公共视图(布局充气机、视图组容器、捆绑包保存状态){
//列表中的每一行存储国家名称、货币和国旗
列表列表=新的ArrayList();

对于(int i=0;i覆盖
onListItemClick
列表片段中,您可以访问单击的项目数据并将其显示在新页面上

public void onListItemClick (ListView l, View v, int position, long id) {
    // do it here
}