Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid custom Listadapter
    text
    copied!<p>I want to let the adapter check if the submitted value is a file but when I check it only checks the first value so for eg.</p> <p>I submit</p> <p>app (directory) meta (directory)</p> <p>this shoul look like this :</p> <p>app with the directory icon meta with the directory icon</p> <p>but the out put is only app as directory</p> <p>The adapter:</p> <pre><code>package org.alexander.fuchs.compress; import java.io.File; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class adapter extends ArrayAdapter&lt;String&gt; { private final Activity context; private final String[] names; static class ViewHolder { public TextView text; public ImageView image; } public adapter(Activity context, String[] names) { super(context, R.layout.rowlayout, names); this.context = context; this.names = names; } @Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = convertView; if (rowView == null) { LayoutInflater inflater = context.getLayoutInflater(); rowView = inflater.inflate(R.layout.rowlayout, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) rowView.findViewById(R.id.label); viewHolder.image = (ImageView) rowView .findViewById(R.id.icon); rowView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) rowView.getTag(); String s = names[position]; holder.text.setText(s); File entry = new File(s); if(entry.isDirectory() == true) { holder.image.setImageResource(R.drawable.ok); } else { holder.image.setImageResource(R.drawable.no); } return rowView; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload