如何将simpleadapter上绑一个onclick事件 30
我需要的效果就是图片上的每一项点击后都会传一个网址在另一个activity里打开,但是不知道怎么绑定onItemClickListener事件我需要把网址塞到Intent...
我需要的效果就是图片上的每一项点击后都会传一个网址在另一个activity里打开,但是不知道怎么绑定onItemClickListener事件
我需要把网址塞到Intent里面传到下一个Activity里打开,下面代码中的map01.put("html", )就是我的网址
package com.jerehsoft.sale.main;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.jerehsoft.platform.R;
import com.jerehsoft.platform.activity.JEREHBaseActivity;
import com.jerehsoft.platform.activity.JEREHBaseSimpleListActivity;
import com.jerehsoft.platform.activity.utils.DataControlResult;
public class MainActivity extends JEREHBaseActivity
{
private ListView qiye_list;
protected DataControlResult controlResult; // TODO 表单对应操作结果类
private int syTag=-1;//TODO 同步标签
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
qiye_list=(ListView)findViewById(R.id.qiye_list);
String[] qiye = new String[] {};
qiye = getResources().getStringArray(R.array.qiye06);
List<Map<String, Object>> qiyelist = new ArrayList<Map<String, Object>>();
for (int i = 0; i < qiye.length; i+=3){
Map<String, Object> map01 = new HashMap<String, Object>();
map01.put("title", qiye[i]);
map01.put("pubtime", qiye[i+1]);
map01.put("html", qiye[i+2]);
map01.put("pic", R.drawable.logo21);
qiyelist.add(map01);
}
SimpleAdapter adapter = new SimpleAdapter(
this,qiyelist,R.layout.qiye__list_layout,new String[]{"pic","title","pubtime"},new int[]{R.id.image,R.id.qiye_title,R.id.qiye_pubtime});
qiye_list.setAdapter(adapter);
qiye_list.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
HashMap<String, Object> item=(HashMap<String, Object>) arg0.getItemAtPosition(arg2);
//这里面该怎么继续写
}});
}
} 展开
我需要把网址塞到Intent里面传到下一个Activity里打开,下面代码中的map01.put("html", )就是我的网址
package com.jerehsoft.sale.main;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.jerehsoft.platform.R;
import com.jerehsoft.platform.activity.JEREHBaseActivity;
import com.jerehsoft.platform.activity.JEREHBaseSimpleListActivity;
import com.jerehsoft.platform.activity.utils.DataControlResult;
public class MainActivity extends JEREHBaseActivity
{
private ListView qiye_list;
protected DataControlResult controlResult; // TODO 表单对应操作结果类
private int syTag=-1;//TODO 同步标签
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
qiye_list=(ListView)findViewById(R.id.qiye_list);
String[] qiye = new String[] {};
qiye = getResources().getStringArray(R.array.qiye06);
List<Map<String, Object>> qiyelist = new ArrayList<Map<String, Object>>();
for (int i = 0; i < qiye.length; i+=3){
Map<String, Object> map01 = new HashMap<String, Object>();
map01.put("title", qiye[i]);
map01.put("pubtime", qiye[i+1]);
map01.put("html", qiye[i+2]);
map01.put("pic", R.drawable.logo21);
qiyelist.add(map01);
}
SimpleAdapter adapter = new SimpleAdapter(
this,qiyelist,R.layout.qiye__list_layout,new String[]{"pic","title","pubtime"},new int[]{R.id.image,R.id.qiye_title,R.id.qiye_pubtime});
qiye_list.setAdapter(adapter);
qiye_list.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
HashMap<String, Object> item=(HashMap<String, Object>) arg0.getItemAtPosition(arg2);
//这里面该怎么继续写
}});
}
} 展开
1个回答
2012-03-12
展开全部
接着写要进行的处理啊,例如页面跳转,那就startActivity啊,当然可以从item中获得你放进去的数据(如"title","pic",),然后传递到另外一个Activity
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询