我正在尝试使用AsyncTask
但我不知道如何使用AsyncTask
。你能帮我改变我的适配器到picaso库到package com.beamreveriestudio.www.bootcamp;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.HashMap;
public class ListAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater = null;
public ListAdapter(Activity a, ArrayList<HashMap<String, String>> d)
{
activity = a;
data = d;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
View vi = convertView;
if (convertView == null) vi = inflater.inflate(R.layout.listdata, null);
TextView judul = (TextView) vi.findViewById(R.id.judul);
TextView alamat = (TextView) vi.findViewById(R.id.alamat);
ImageView thumb_image = (ImageView) vi.findViewById(R.id.gambar);
HashMap<String, String> daftar = new HashMap<String, String>();
daftar = data.get(position);
alamat.setText(daftar.get(Daftarwisata.TAG_ALAMAT));
judul.setText(daftar.get(Daftarwisata.TAG_NAMA));
Picasso.with(activity.getApplicationContext())
.load(daftar.get(Daftarwisata.TAG_GAMBAR))
.error(R.mipmap.ic_launcher)
.into(thumb_image);
return vi;
}
}
吗?
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "Button Clicked";
if (Control.ModifierKeys == Keys.Control) label1.Text += " with Ctrl";
}
private void button1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\n') button1_Click(sender, new EventArgs());
}