제목, 요약 및 아이콘을 사용하는 사용자 정의 환경 설정을 사용하고 있습니다. 기본 설정은 항목 (스킨, 응용 프로그램 등)을 선택한 다음 그 항목을 선택하는 데 사용됩니다. 현재의 선택을 요약 할 것이다. 여기에 제대로 (위) 작업 환경 및 허니컴/ICS에 내 문제는 다음과 같습니다Honeycomb/ICS에서 사용자 정의 기본 설정이 깨졌습니다.
공간은 기본 설정에 대해 이루어지고 있지만, 심지어 기본 제목/요약 게재되지 않습니다 , 항목 선택의 의도도 발화되지 않습니다.
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+android:id/widget_frame"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignLeft="@android:id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:maxLines="2" />
</RelativeLayout>
<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center" />
</LinearLayout>
그리고 사용자 환경 자체 : 기본 설정 자체가 너무 흥미로운
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
public class SelectedAppPreference extends Preference {
private Drawable mIcon;
public SelectedAppPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final PackageManager pm = context.getPackageManager();
String packageName = context.getSharedPreferences("appPrefs", Context.MODE_PRIVATE).getString("selected_app_package", null);
this.setLayoutResource(R.layout.icon_pref);
try {
this.mIcon = pm.getApplicationIcon(packageName);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
public SelectedAppPreference(Context context, AttributeSet attrs) {
super(context, attrs);
final PackageManager pm = context.getPackageManager();
String packageName = context.getSharedPreferences("appPrefs", Context.MODE_PRIVATE).getString("selected_app_package", null);
this.setLayoutResource(R.layout.icon_pref);
try {
this.mIcon = pm.getApplicationIcon(packageName);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
@Override
protected void onBindView(final View view) {
super.onBindView(view);
final ImageView imageView = (ImageView)view.findViewById(R.id.icon);
if ((imageView != null) && (this.mIcon != null)) {
imageView.setImageDrawable(this.mIcon);
}
}
public void setIcon(final Drawable icon) {
if (((icon == null) && (this.mIcon != null)) || ((icon != null) && (!icon.equals(this.mIcon)))) {
this.mIcon = icon;
this.notifyChanged();
}
}
public Drawable getIcon() {
return this.mIcon;
}
}
아무것도 여기에 기본 레이아웃입니다. 문제가 기본 레이아웃 xml에 있다는 느낌이 들지만 정확하게 작동하지 않는 것은 무엇인지 확실하지 않습니다. Android 2.1, 2.2 및 2.3 장치에서 기본 설정이 제대로 작동하는지 확인할 수 있으며 3.2 및 4.0에 대한 문제가 있습니다. 어떤 제안?
링크가 죽었습니다 .. – marcinj