Android的ListView的烤面包的消息问题

编程入门 行业动态 更新时间:2024-10-26 08:26:50
本文介绍了Android的ListView的烤面包的消息问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个问题,我有一个活动1:活动,用下面的code:

i have the next problem, i have an Activity1 : Activity, with the following code:

private string[] items; public ListView lv; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); ListView lv = FindViewById<ListView>(Resource.Id.listView1); items = new string[] { "Aaaa", "bbb", "cccc", "dddd", "eeee", "ffff", "gggg" }; var ListAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, items); lv.Adapter = ListAdapter; } protected void OnListClick(ListView listView, View view, int pos, long id) { var t = items[pos]; Android.Widget.Toast.MakeText(this, t, Android.Widget.ToastLength.Short).Show(); } }

问题如下,当我调试应用程序,并单击某一行上,没有出现敬酒消息,没什么......一些帮助PLS .....

The problem is as follows, when i debug the app, and click on a row, no toast message appears, nothing...... some help pls.....

在xml:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:p1="schemas.android/apk/res/android" p1:orientation="horizontal" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="fill_parent" p1:layout_height="fill_parent" p1:id="@+id/linearLayout1"> <LinearLayout p1:id="@+id/layoutCalendar" p1:orientation="horizontal" p1:layout_width="200.0dp" p1:layout_height="fill_parent" p1:layout_gravity="right" p1:minWidth="25px" p1:minHeight="25px"> <ListView p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="wrap_content" p1:layout_height="fill_parent" p1:id="@+id/listView1" /> </LinearLayout> <calendarcontrol.CalendarMonthView p1:id="@+id/calendarView2" p1:clickable="true" p1:layout_width="wrap_content" p1:layout_height="wrap_content" p1:layout_gravity="right" />

推荐答案

使用onItemSelectListener代替的onClick的

use onItemSelectListener instead of onClick

public class AppActivity extends Activity { public Activity activity; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); activity = this; ListView lv = FindViewById<ListView>(Resource.Id.listView1); items = new string[] { "Aaaa", "bbb", "cccc", "dddd", "eeee", "ffff", "gggg" }; var ListAdapter = new ArrayAdapter<String>(this, android.Resource.Layout.SimpleListItem1, items); lv.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View childView, int position, long id) { var t = items[position]; Android.Widget.Toast.MakeText(activity, t, Android.Widget.ToastLength.Short).Show(); } }); lv.Adapter = ListAdapter; } }

更多推荐

Android的ListView的烤面包的消息问题

本文发布于:2023-10-16 11:44:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497458.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   烤面包   Android   ListView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!