Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implements a ListFragment into your project from a Sample?
    primarykey
    data
    text
    <p>I have a Pager adapter that will call a ListFragment like this:</p> <pre><code>public Fragment getItem(int position) { Fragment fragment = new ListViewFragment(); // set arguments here, if required Bundle args = new Bundle(); fragment.setArguments(args); return fragment; </code></pre> <p>Then I have a ListActivity that I want to change to ListViewFragment.</p> <pre><code>public class ImageListActivity extends ListActivity implements RadioGroup.OnCheckedChangeListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.imagelist); RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup); radioGroup.setOnCheckedChangeListener(this); setListAdapter(new ImageAdapter()); } public void onCheckedChanged(RadioGroup group, int checkedId) { ImageDownloader.Mode mode = ImageDownloader.Mode.NO_ASYNC_TASK; if (checkedId == R.id.correctButton) { mode = ImageDownloader.Mode.CORRECT; }else if (checkedId == R.id.randomButton) { mode = ImageDownloader.Mode.NO_DOWNLOADED_DRAWABLE; } ((ImageAdapter) getListAdapter()).getImageDownloader().setMode(mode); } } </code></pre> <p>But I really cant put it to work.. Ive tried that:</p> <pre><code>public class ListViewFragment extends ListFragment { int mNum; Context ctx; View v; static int p; /** * Create a new instance of CountingFragment, providing "num" * as an argument. */ static ListFragment newInstance(int num) { ListFragment f = new ListFragment(); // Supply num input as an argument. Bundle args = new Bundle(); args.putInt("num", num); f.setArguments(args); return f; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.imagelist, container, false); ImageDownloader.Mode mode = ImageDownloader.Mode.NO_ASYNC_TASK; mode = ImageDownloader.Mode.CORRECT; ((ImageAdapter) getListAdapter()).getImageDownloader().setMode(mode); setListAdapter(new ImageAdapter()); return container; } } </code></pre> <p><strong>UPDATE:</strong> - I just answer my own question and I make a little tutorial to explain beginners how to implements a ListAdapter into your project from a sample.</p> <p>I´ve got this ListAdapter from a sample, and just copy the files to my project, if you run it, will crash.</p> <p>So, you need to follow my answer and made the changes and implements whatever <code>ListArrayAdapter</code> that you found in internet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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