gpt4 book ai didi

android - 隐形 ListView 项目 [发布 APK]

转载 作者:搜寻专家 更新时间:2023-11-01 09:20:37 27 4
gpt4 key购买 nike

我有一个 ListView 项目。在 Debug 模式下,我能够看到 ListView 的所有项目,但是当我生成发布 APK 时,ListView 的所有项目都是不可见的,但仍然可以点击,只是项目的文本是不可见的。当我禁用 pro guard 时一切正常。我使用 Gson 将 JSON 转换为 java 对象。

PROGUARD:

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

##---------------End: proguard configuration for Gson ----------

更新:

助手:

public class PlazaHelper {
public static List<PlazaModel> retrievePlazaHelper(Context context) {
Reader reader = new InputStreamReader(context.getResources().openRawResource(R.raw.nightwaveplazalinks));
return (new Gson()).fromJson(reader, new TypeToken<List<PlazaModel>>() {
}.getType());
}
}

型号

public class PlazaModel {

private String name;

@SerializedName("stream")
private String url;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}

适配器

public class PlazaListAdapter extends BaseAdapter {

private Activity activity;
private List<PlazaModel> PlazaModels;

public PlazaListAdapter(Activity activity, List<PlazaModel> PlazaModels) {
this.activity = activity;
this.PlazaModels = PlazaModels;
}

@Override
public int getCount() {
return PlazaModels.size();
}

@Override
public Object getItem(int position) {
return PlazaModels.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
ViewHolder holder;
if (view != null) {
holder = (ViewHolder) view.getTag();
} else {
view = inflater.inflate(R.layout.list_item_style, parent, false);
holder = new ViewHolder(view);
view.setTag(holder);

}
PlazaModel plazaModel = (PlazaModel) getItem(position);
if (plazaModel == null) {
return view;
}
holder.text.setTextColor(Color.BLACK);
holder.text.setText(plazaModel.getName());
return view;
}

static class ViewHolder {
TextView text;

ViewHolder(View view) {
text = view.findViewById(R.id.txt_result);
}
}
}

最佳答案

You should keep the names of all public classes in the specified package & its subpackages.

-keep class packageName.subPackageName.** { *; }

关于android - 隐形 ListView 项目 [发布 APK],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56131390/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com