第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何通過 json 將本地圖像(可繪制圖像文件)顯示到 cardview。

如何通過 json 將本地圖像(可繪制圖像文件)顯示到 cardview。

慕哥6287543 2021-06-29 09:15:43
如何將本地圖像(可繪制圖像文件)顯示到cardviewvia json. 我想離線加載圖像而不是使用畢加索庫我正在使用選項(xiàng)卡布局和我的 Frament.java@Nullable@Overridepublic View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {    View rootView = inflater.inflate(            R.layout.fragment, container, false);    return rootView;}@Overridepublic void onViewCreated(View view, @Nullable Bundle savedInstanceState) {    super.onViewCreated(view, savedInstanceState);    final ArrayList<Website> babyList = Website.getbabyFromFile("baby&kids.json", getActivity());    adapter = new WebsiteAdapter(this, babyList);    recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(),2));    recyclerView.setAdapter(adapter);}
查看完整描述

1 回答

?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

如果你有繪制文件夾下的本地圖片為所有一)myntra B)firstCry C)跳房子等等,那么你只是單純的需要得到基于URL正確繪制。您可以創(chuàng)建工廠類,它將為您提供@DrawableRes


    public static @DrawableRes int getDrawable(String url){

        if(url.contains("Myntra")) {

            return R.drawable.myntra;

        } else if(url.contains("Snapdeal")) {

            return R.drawable.snapdeal;

        }

        // Add other if else to support other website url

    }

這是修改后的 onBindViewHolder 方法。


@Override

public void onBindViewHolder(WebsiteAdapter.ViewHolder holder, int position) {

   Website website = mDataSource.get(position);

   holder.url.setText(website.getUrl());

   holder.thumbnailImageView.setImageResource(getDrawable(website.getUrl()));

}


查看完整回答
反對 回復(fù) 2021-07-07
  • 1 回答
  • 0 關(guān)注
  • 147 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)