如何正确地实现从一个搜索活动 listview动态添加item onClickItem

android 点击 listview中的Item跳转到另一个activity?
不知道你是怎么实现的? 我可以给你一段我写的代码
你参考一下
首先是要添加适配器的public class PublishCommentActivity extends Activity { private PublishCommentListAdapter listViewA// 适配器 private List&Map&String, String&& getD private ImageB private ListView pulishcommentL // 声明listview // private MyRatingBarLarge ratingBar1,ratingBar2; @Override protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// 去掉标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.publish_comment);
returnprev = (ImageButton) findViewById(R.id.publish_comment_returnprev);
this.returnprev.setOnClickListener(returnprevClick);
pulishcommentList = (ListView) findViewById(R.id.listView1);
List&String& trList = JsonAnalysisData.userJnD
String userId = trList.get(0).toString();
Log.i("chen================", userId);
Map&String, String& miss = new HashMap&String, String&();//
String json =
// 字段,String userId,String goodsId,String logisticsId,String
// content,String degree,String agreement,String speed,String
// satisfact,String createtime,String isAnonymous
miss.put("userId",userId); // 用户Id
miss.put("goodsId", goodsId);// 商品Id
miss.put("logisticsId", logisticsId);// 物流Id
miss.put("content", content);// 评论内容
miss.put("degree", degree);// 评论等级(好评 中评 差评)
miss.put("agreement", agreement); //,满意度
miss.put("speed", speed); // 发货速度
miss.put("satisfact", satisfact);// 单个商品的满意度
miss.put("createtime", createtime);// 评论时间
miss.put("isAnonymous", isAnonymous);//
Log.i("super&&&&&&&&&&&&&&&&&&&&&&&&&",userId);
// 获取数据
String json = HttpUtil.submitPostData(miss, "utf-8",
MENTARY_ADD_URL).toString();
this.getAddressAdapter(); } /**
* 给List&AddressList&设置适配器方法
*/ private void getAddressAdapter() {
// 实例化addressListData获取数据
this.getData = mentD
// Log.i("chen", getString(addressListData.size()));
// 判断数据源是否为空
if (getData.size() & 0) {
// 调用自定义adapter 参数1:要显示到的Activity 参数2:数据(list)
listViewAdapter = new PublishCommentListAdapter(getData,
R.layout.publish_comment_item, this);
// 添加addressListAdapter到addressList中
this.pulishcommentList.setAdapter(listViewAdapter);
已有帐号?
无法登录?
社交帐号登录如何正确地实现从一个搜索activity listview onClickItem_百度知道<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&如何通过其他控件去触发listview的itemonclick事件呢? -Android- TryCatch
>> Content
如何通过其他控件去触发listview的itemonclick事件呢?
本帖最后由 fish007fish2003 于
10:34:23 编辑
------Solutions------
ListView.performItemClick()
------Solutions------
里面不是还需要三个参数吗?不是很明白,给个例子吧。谢谢,刚接触android,不是很明白,谢谢引用楼主&fish007fish2003&的回复:比如说我想通过一件button的去触发点击listview中第一项的itemonclick事件,我是这么写的,第一项只是高亮显示,却没有触发itemonclick事件。大家帮帮忙。public&void&onClick(View&v)&{listView&=&Activity.this.getListView();listView.requestFocusFromTouch();&……3447人阅读
Android(78)
& 最近在做一个项目,需要用到像IPone删除的效果,即在item上左滑弹出删除的按钮。找了一些资料,发现在github上有个SwipeListView的项目可以实现这个功能。下面介绍一下SwipeListView的使用方法。
& 1、下载library和demo:。
& 2、下载依赖lib&nineoldandroids-2.4.0.jar:。
& 3、解压SwipeListView文件,在eclipse里导入swipeListView的lib项目,把nineoldandroids-2.4.0.jar和android-support-v4.jar加入到libs下面。
& 4、导入demo项目,引入swipeListView库。
& 5、swipeListView的用法,在布局文件里:&LinearLayout xmlns:android=&/apk/res/android&
xmlns:swipe=&/apk/res-auto&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:background=&@color/background_app&
android:orientation=&vertical& &
&com.fortysevendeg.swipelistview.SwipeListView
android:id=&@+id/example_lv_list&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:listSelector=&#&
swipe:swipeBackView=&@+id/back&
swipe:swipeCloseAllItemsWhenMoveList=&true&
swipe:swipeDrawableChecked=&@drawable/choice_selected&
swipe:swipeDrawableUnchecked=&@drawable/choice_unselected&
swipe:swipeFrontView=&@+id/front&
swipe:swipeMode=&both& /&
&/LinearLayout&& item布局文件:
&FrameLayout xmlns:android=&/apk/res/android&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent& &
&LinearLayout
android:id=&@+id/back&
style=&@style/ListBackContent&
android:tag=&back& &
android:id=&@+id/example_row_b_action_1&
style=&@style/ListButtonAction&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&@string/open& /&
android:id=&@+id/example_row_b_action_2&
style=&@style/ListButtonAction&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&@string/googlePlay& /&
android:id=&@+id/example_row_b_action_3&
style=&@style/ListButtonAction&
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:text=&@string/uninstall& /&
&/LinearLayout&
&RelativeLayout
android:id=&@+id/front&
style=&@style/ListFrontContent&
android:orientation=&vertical&
android:tag=&front& &
&ImageView
android:id=&@+id/example_row_iv_image&
style=&@style/ListImage& /&
android:id=&@+id/example_row_tv_title&
style=&@style/ListTitle&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:layout_toRightOf=&@id/example_row_iv_image& /&
android:id=&@+id/example_row_tv_description&
style=&@style/ListDescription&
android:layout_width=&fill_parent&
android:layout_height=&wrap_content&
android:layout_below=&@id/example_row_tv_title&
android:layout_toRightOf=&@id/example_row_iv_image& /&
&/RelativeLayout&
&/FrameLayout&& 代码:
adapter = new PackageAdapter(this, data);
swipeListView = (SwipeListView) findViewById(R.id.example_lv_list);
if (Build.VERSION.SDK_INT &= 11) {
swipeListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.HONEYCOMB) {
swipeListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
mode.setTitle(&Selected (& + swipeListView.getCountSelected() + &)&);
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
int id = item.getItemId();
if (id == R.id.menu_delete) {
swipeListView.dismissSelected();
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.menu_choice_items, menu);
public void onDestroyActionMode(ActionMode mode) {
swipeListView.unselectedChoiceStates();
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
public void onOpened(int position, boolean toRight) {
public void onClosed(int position, boolean fromRight) {
public void onListChanged() {
public void onMove(int position, float x) {
public void onStartOpen(int position, int action, boolean right) {
Log.d(&swipe&, String.format(&onStartOpen %d - action %d&, position, action));
public void onStartClose(int position, boolean right) {
Log.d(&swipe&, String.format(&onStartClose %d&, position));
public void onClickFrontView(int position) {
Log.d(&swipe&, String.format(&onClickFrontView %d&, position));
public void onClickBackView(int position) {
Log.d(&swipe&, String.format(&onClickBackView %d&, position));
public void onDismiss(int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
data.remove(position);
adapter.notifyDataSetChanged();
swipeListView.setAdapter(adapter);
& 以上就是SwipeListView的用法。
& 注:设置swipeListView的模式要在adapter更新数据之后。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:138382次
积分:2172
积分:2172
排名:第13127名
原创:91篇
转载:13篇
评论:13条
(2)(3)(1)(1)(2)(5)(3)(6)(10)(13)(57)(1)

我要回帖

更多关于 listview设置item间距 的文章

 

随机推荐