在listview中下载.doc .pdf文件

时间:2016-05-28 03:38:04

标签: java android listview android-studio download

我仍然是Android工作室的新手..所以我想在我的listview中进行按钮下载,但我无法想象如何让它工作。所以这里是Adapter.java

public class JurnalAdapter extends ArrayAdapter<Jurnal> {
private Context context;


public JurnalAdapter(Context context, ArrayList<Jurnal> jurnalArrayList) {
    super(context, 0, jurnalArrayList);
    this.context = context;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(this.context);
    convertView = inflater.inflate(R.layout.list_jurnal_item, parent, false);

    final Jurnal jurnal = getItem(position);

    Button download = (Button) convertView.findViewById(R.id.bDownload);
    ImageView nama_gambar = (ImageView) convertView.findViewById(R.id.ivNamaGambar);
    TextView fullname = (TextView) convertView.findViewById(R.id.tvFullname);
    TextView nama_jurnal = (TextView) convertView.findViewById(R.id.tvNamaJurnal);
    TextView desc_jurnal = (TextView) convertView.findViewById(R.id.tvDescJurnal);
    TextView nama_naskah = (TextView) convertView.findViewById(R.id.tvNamaNaskah);

    String mName = " Penulis : ";
    String mJurnal = " Judul jurnal : ";
    String mDesc = " Abstrak : ";
    String mNaskah = " Nama dokumen : ";


    final String baseUrlFoto = "http://jurnalonline.esy.es/showbox/uploads/";
    String UrlFotoJurnal = baseUrlFoto + jurnal.getNama_gambar();
    Picasso.with(this.context).load(UrlFotoJurnal).into(nama_gambar);

    fullname.setText(mName + jurnal.getFullname().toString());
    nama_jurnal.setText(mJurnal + jurnal.getNama_jurnal().toString());
    desc_jurnal.setText(mDesc + jurnal.getDesc_jurnal().toString());
    nama_naskah.setText(mNaskah + jurnal.getNama_naskah().toString());


    download.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          //this string strUrl to find the url of my .doc or .pdf files
          String strUrl = baseUrlFoto + jurnal.getNama_naskah().toString();

          //this line will transfer strUrl to downloadFile.class
          new downloadFile().execute(strUrl);

        }
    });



    return convertView;

    }

}

我试图在这里搜索我的问题但是当我尝试将代码实现到我的代码时它会出错。任何建议都会被接受

0 个答案:

没有答案