如何在Android中添加列表首选项中每个项目旁边的图标以及选定的指示器
我正在处理一个Xposed模块,我需要在我的首选项列表中的每个项目旁边都有一个图标。 我能够做到这一点: 但我想要的正是这个: 我的Java类文件:如何在Android中添加列表首选项中每个项目旁边的图标以及选定的指示器,android,listview,android-preferences,preferenceactivity,listpreference,Android,Listview,Android Preferences,Preferenceactivity,Listpreference,我正在处理一个Xposed模块,我需要在我的首选项列表中的每个项目旁边都有一个图标。 我能够做到这一点: 但我想要的正是这个: 我的Java类文件: package ic.lunar.xposed.exthemer.list.preferences; import ic.lunar.xposed.exthemer.R; import android.content.Context; import android.preference.ListPreference; import android
package ic.lunar.xposed.exthemer.list.preferences;
import ic.lunar.xposed.exthemer.R;
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;
public class Sim_Icon_List_Preference extends ListPreference {
Context context;
public Sim_Icon_List_Preference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
setDialogLayoutResource(R.layout.activity_my_list_preference); //inherited from DialogPreference
}
}
我的布局Xml文件:
当您需要一个每行带有文本和图标的ListPreference时,您可以通过它找到解决方案 你必须使用自定义列表视图我使用了这个选项,然后只得到了图标。但是我希望图标位于每个商品名称的旁边。你可以发布定制商品的xml设计吗。请尽快帮我解决了吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MyListPreference" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/tw_sim_icon_home" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_toRightOf="@+id/imageView1"
android:src="@drawable/tw_sim_icon_heart" />
</RelativeLayout>