- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
请引用这张图片https://www.dropbox.com/s/6zoj9lw10oc07xa/to_dropbox.png
我在做什么:
我正在创建一个 list_view ,我正在其中添加自定义适配器。
我正在使用什么:
我正在使用,listView,customAdapter,menuitem。listView
: 整个应用程序中的单个 ListView customadapters
:3 个自定义适配器菜单项
: 1
我是如何实现的:
我有从中正确获取内容的数据库,并且从该数据库中我通过过滤 3 种类型的数据在我的 ListView 中输入了这些值:默认输入第一个 adapter_type(在 onCreate 中)。
adapter = new Adapter_forCompletedReminder( array_today_title , this) ;
ls.setAdapter(adapter) ;
通过按 menuitem 在我的 ListView 中输入第二个 adapter_type 。
adapter = new Adapter_forCompletedReminder( array_past_2_day_title , this) ;
ls.setAdapter(adapter) ;
通过按 menuitem 在我的 ListView 中输入第三个 adapter_type 。
adapter = new Adapter_forCompletedReminder( array_other_day_title , this) ;
ls.setAdapter(adapter) ;
我的问题是什么:
此代码添加到 onCreate() 方法中。
ls.setOnItemClickListener( new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> adapterView , View view , int position ,long arg3)
{
Log.i("Item clicked","tushar:itemclicked") ;
}
});
当我尝试实现 AdapterView.OnItemClickListener() 时,它不起作用......代码没有崩溃(log cat 中没有红线)。单击 llist_view_element 时代码未执行
谢谢,阅读我的问题。
最佳答案
您在 customview_completedxml_listview.xml 中使用复选框,这就是 onItemClick 监听器不起作用的原因。如果您在复选框中设置 clickable = "false",则 onItemclick 监听器将起作用。
如果您希望该复选框仍然有效,那么您必须在自定义适配器类中设置 onclicklistener 事件。
//我编辑getView
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = LayoutInflater.from(ob) ;
View v = inflater.inflate(R.layout.customview_completedxml_listview, null ) ;
TextView txt = ( TextView ) v.findViewById(R.id.txt_fordisplayingdata) ;
txt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(ob, "Hello", Toast.LENGTH_SHORT).show();
}
});
txt.setText(recieved_Array[position]) ;
return v ;
}
////////////////////////第二个解决方案在复选框中设置 android:focusable="false"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
>
<TextView
android:id="@+id/txt_fordisplayingdata"
android:layout_width="240dp"
android:text="display data"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
/>
<TextView
android:id="@+id/txt_fordisplayingLargerdata"
android:layout_width="240dp"
android:text="display data larger bahut larger "
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:visibility="gone"
/>
<View
android:layout_width="2dp"
android:layout_toRightOf="@id/txt_fordisplayingdata"
android:layout_height="15dp"
android:layout_marginLeft="15dp"
android:layout_centerVertical="true"
android:id="@+id/view_forcompletedtask"
/>
<CheckBox
android:layout_toRightOf="@id/view_forcompletedtask"
android:id="@+id/checkbox_tocomplete"
android:layout_marginLeft="15dp"
android:layout_width="wrap_content"
android:focusable="false"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
/>
</RelativeLayout>
关于android - AdapterView.OnItemClickListener() 在我的 customAdapter 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16913783/
问题是我正在尝试更新 ListView 中的所有按钮,按钮在我编写的 CustomAdapter 中,但按钮没有被更新。所以我的想法是更改 ListView 中所有按钮的文本并在单击按钮后显示计时器,
我正在尝试使用自定义适配器创建卡片 View 列表。我在单独的 .xml 文件中定义了单行列表的布局,其中包含卡片 View 和 ImageView / TextView 。我正在使用自定义 srrs
我是 Android Studio 和一般编码的新手,我正在尝试显示带有颜色图像和颜色名称的自定义 ListView。我使用了一个自定义适配器来使用两个包含可绘制图像颜色和名称字符串的数组来扩展 Vi
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 7 年前。 public class Jso
所以我在特定行上得到这个 ClassCastException: Java: private class MyArrayAdapter extends ArrayAdapter // My custo
我创建了一个自定义适配器以将我的元素发送到我的适配器类。 我的项目: public ItemAcompanhe(String dataPar, String cabecalhoPar, Strin
所以这里是我的问题的总结。我正在创建一个测试应用程序只是为了提高我在 android 方面的技能,并且我创建了一个列出公交时刻表的特定 Activity 。所以基本上,整个页面只显示每次旅行的旅行#、
每次向上或向下滚动时,我的 CustomAdapter 中的 getView() 方法都会被调用。 @Override public View getView(int position, View c
这是我用过的教程:http://www.tutorialsbuzz.com/2014/08/filter-custom-listviewbaseadapter.html 我为它实现了一个onItemC
我正在尝试构建一个 ArrayAdapter,允许用户访问链接到互联网、谷歌地图等的各个 TextView 字段。我无法解决错误状态为 Cannot resolve method 'startActi
我在这里陷入困境,我想将 OnItemClickListener 集成到我的 CustomAdapter 中,因此当单击某个项目时,它会显示一些消息或其他内容。但我不确定在哪里设置它。我看过很多教程和
我有一个自定义 TextView,我在自定义 GridView 适配器中使用它。自定义 TextView 使用自定义字体进行翻译。这在默认安装了语言环境的设备中效果相当好。 但是,在未安装该语言的设备
在我的应用程序中,我有 ListView,它由我的 CustomAdapter(即 ArrayAdapter)设置。 CustomAdapter 在其中实现了 ViewHolder,它引用了我的 Cu
所以我潜伏了一段时间,试图找到这个问题的答案。我在探洞。我需要一双全新的眼睛。我的 CustomAdapter 中的 View getView 未被调用。 public class User_List
我看过很多关于不同 CustomAdapter 的演示,但是这两个演示都没有展示我们如何在适配器内部实际获取我们正在使用适配器的 Activity 。现在我正在为适配器使用这种方法 private A
这是我完成的 android studio 项目编码:我知道我犯了多个错误,但在哪里??我是新手 这是我的 MainActivity 类: public class MainActivity exte
我想创建 ListView使用扩展 BaseAdapter 的 CustomAdapter .我有CustomAdapter(Context context, List> dataList) . 如何
我正在为 ListView 扩充两种不同的布局。一切正常,直到我开始向下滚动,开始随机应用 2 种不同的布局。我在这里遵循了其他示例,但我无法使其正常工作。有什么建议吗? public class C
我有一个 Fragment,使用 CustomAdapter(extending BaseAdapter) 加载了 GridView。数据是从服务器检索的,因此,一旦下载完成,我将尝试在适配器上调用
我是 Android Studios 的新手,我无法从我的 CustomAdapter 类中调用新 Activity 。在该应用中,用户应该单击 ListView 中的文本并打开一个显示联系人各自详细
我是一名优秀的程序员,十分优秀!