Как управлять компоновкой пользовательских настроек

У меня есть пользовательское предпочтение с изображением и двумя текстами, и мне нужно программно изменить изображение.

Я могу получить представление пользовательских настроек и найти ImageView в макете с помощью findViewById, но если я попытаюсь изменить изображение, это не сработает.

Я что-то не так?

ПРЕДПОЧТИТЕЛЬНЫЙ МАКЕТ

 <?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>

КОД ДЛЯ ИЗМЕНЕНИЯ СОДЕРЖИМОГО 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);
5
задан Giuseppe 3 August 2012 в 09:14
поделиться