1

MainActivity.java にこのようなものがあります

m_dbmanager.addRow(
                "http://pl.wikipedia.org/wiki/1_stycznia",
                "1",
                "http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg");

最初の引用は別のアクティビティで webview に送信するリンク、2 番目の引用 ("1") は行の名前、最後の 3 番目の引用は行に表示したい画像への URL です。

これが、画像とのやり取りを担当するコードの一部です。

public View getView(int position, View convertView, ViewGroup parent) 
        {
                View v = convertView;
                if (v == null) 
                {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row, null);
                }
                Order o = items.get(position);
                if (o != null) 
                {
                        TextView name = (TextView) v.findViewById(R.id.row_textView);
                        ImageView image_view = (ImageView) v.findViewById(R.id.row_imageView);


                       if (name != null) 
                       {
                            name.setText("Name: "+o.getOrderName());                            
                       }
                       if(image_view != null)
                       {

                            final String thumbail = o.getOrderImage(); //TODO, just trying
                            final String link = o.getOrderLink();

                            image_view.setOnClickListener(new View.OnClickListener()

                            {
                                public void onClick(View view)
                                {       
                                    Intent intent = new Intent(MainActivity.this, TemplateActivity.class);
                                    intent.putExtra("urlString", link);
                                    startActivity(intent);
                                }
                            });
                        }
                }
                return v;
        }
    }

誰かが見たい場合に備えてクラスを注文する

オブジェクト「row_imageView」の代わりに addRow で指定された URL から画像を表示するにはどうすればよいですか?

前もって感謝します、

4

1 に答える 1

1

Picasso ライブラリを使用して、URL から ImageView に画像を読み込むことができます。

jar をダウンロードして、プロジェクトの libs フォルダーに追加します。次に、以下のコードを使用して、URL またはその他のリソースから画像を ImageView に読み込みます。

Picasso.with(your_context).load(url_of_image).placeholder(R.drawable.icon)
       .noFade().into(your_imageView);
于 2014-09-10T12:49:26.800 に答える