相关疑难解决方法(0)

如何使用 PreferenceFragmentCompat 添加可以在 PreferenceScreen 内编辑的图像视图?

似乎 PreferenceScreen 中不支持开箱即用的 ImageView,我该如何实现它,使其与 whatsapp 类似。 在此处输入图片说明

android android-preferences android-imageview

8
推荐指数
1
解决办法
1247
查看次数

如何管理自定义首选项布局

我有一个图像和两个文本的自定义首选项,我需要以编程方式更改图像.

我能够获取自定义首选项视图并使用findViewById在布局中找到ImageView,但如果我尝试更改图像,则无效.

我错了什么?

优惠配额

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >


    <ImageView
        android:id="@+id/imageforfacebook"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:padding="5dip"
        android:src="@drawable/icon" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fadingEdge="horizontal"
            android:singleLine="true"
            android:text="titolo"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textSize="18sp" />

        <TextView
            android:id="@+android:id/summary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@android:id/title"
            android:layout_below="@android:id/title"
            android:maxLines="2"
            android:text="descrizione"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

代码改变IMAGEVIEW内容

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

View v = (View) prefs_facebookimage.getView(null, null);
ImageView img = (ImageView) v.findViewById(R.id.imageforfacebook);
Uri uri = Uri.parse(path);
img.setImageURI(uri);
Run Code Online (Sandbox Code Playgroud)

android android-layout

5
推荐指数
2
解决办法
7359
查看次数