Adapter実装WIP

This commit is contained in:
ろむねこ 2024-01-25 16:42:08 +09:00
parent 71986bb17d
commit 7eb87305ea
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -1,7 +1,11 @@
package one.nem.lacerta.setting;
import android.media.Image;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@ -27,12 +31,20 @@ public class TagListItemAdapter extends RecyclerView.Adapter<TagListItemAdapter.
@NonNull
@Override
public TagListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.tag_list_full_item, parent, false);
return new TagListItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull TagListItemViewHolder holder, int position) {
DocumentTag documentTag = documentTags.get(position);
holder.tag_name.setText(documentTag.getName());
try {
holder.tag_icon.setImageResource(one.nem.lacerta.shared.ui.R.drawable.class.getField(documentTag.getIcon()).getInt(null));
} catch (Exception e) {
holder.tag_name.setText("Sorry, Parse Error occurred");
}
}
@Override
@ -42,8 +54,15 @@ public class TagListItemAdapter extends RecyclerView.Adapter<TagListItemAdapter.
public static class TagListItemViewHolder extends RecyclerView.ViewHolder {
ImageView tag_icon;
TextView tag_name;
public TagListItemViewHolder(@NonNull View itemView) {
super(itemView);
tag_icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.tag_icon);
tag_name = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.tag_name);
}
}
}