Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to use a <code>ListView</code>... then you should parse you <code>JSON</code> file into some kind of data structure like a List or an <code>ArrayList</code> and the n use an adapter to populate the <code>ListView</code> data.</p> <p><strong>Here is an example for <code>ListView</code> adapter:</strong></p> <pre><code> private class MySecondAdapter extends ArrayAdapter&lt;MiniTask&gt; { private ArrayList&lt;MiniTask&gt; list; public MySecondAdapter(Context context, int textViewResourceId, ArrayList&lt;MiniTask&gt; miniTaskList) { super(context, textViewResourceId, miniTaskList); this.list = new ArrayList&lt;MiniTask&gt;(); this.list.addAll(miniTaskList); } public View getView(final int position, View convertView, ViewGroup parent) { miniTask = miniTaskList.get(position); ViewHolder holder = new ViewHolder(); { LayoutInflater inflator = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflator.inflate(R.layout.check_list_item_new, null); holder.title = (TextView) convertView.findViewById(R.id.tvItemTitle); holder.commentsPicturesButton = (ImageView) convertView.findViewById(R.id.iAddCommetOrPicture); holder.commentsPicturesButton.setTag(position); holder.commentsPicturesButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), PicturesAndCommentsActivity.class); intent.putExtra(TasksListActivity.KEY_ID, task.getId()); intent.putExtra("mini_task_text", miniTask.getTitle()); startActivity(intent); } }); holder.selected = (CheckBox) convertView.findViewById(R.id.cbCheckListItem); holder.selected.setTag(position); holder.selected.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { Log.d(TAG, "pressed the checkbox: " + v.getId() + " in position: " + position + " tag: " +v.getTag() +" and item from array: " + miniTaskList.get(position) ); CheckBox checkbox = (CheckBox) v; miniTaskList.get(position).setSelected(checkbox.isChecked()); numOfCheckedMiniTasks = 0; for(int i=0;i&lt;miniTaskList.size();i++) { miniTask = miniTaskList.get(i); if(miniTask.isSelected()) { numOfCheckedMiniTasks ++; } } int percent = (int)(numOfCheckedMiniTasks * 100.0f) / miniTaskList.size(); Log.d(TAG, "the percentage is: " +percent); tasksRepository.get(tasksRepository.indexOf(task)).setMiniTasksPercentageComplete(percent); } } }); } holder.title.setText(miniTask.getTitle()); holder.selected.setChecked(miniTask.isSelected()); return convertView; } } </code></pre> <p>Check this tutorials for getting more information:</p> <p><a href="http://cyrilmottier.com/2012/02/16/listview-tips-tricks-5-enlarged-touchable-areas/" rel="nofollow">http://cyrilmottier.com/2012/02/16/listview-tips-tricks-5-enlarged-touchable-areas/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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