0

i'm still new on android studio.. so i want to make a button download in my listview but i cant figure it how to make it work. So here is 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;

    }

}

I've tried to search my problem in here but it keeps error when i try to implementing their code to my code. Any suggestions will accepted

  • now i'm trying to implement this code http://stackoverflow.com/questions/6515254/file-download-on-button-click, like this : DownloadFromUrl(strUrl); but comes with an error "jurnal.getNama_Naskah().toString() is redundant" – Jokurilisme May 28 '16 at 04:53
  • did you find any solution?? – Payal Sorathiya Feb 03 '17 at 10:58

0 Answers0