Example usage for android.widget ListView setAdapter

List of usage examples for android.widget ListView setAdapter

Introduction

In this page you can find the example usage for android.widget ListView setAdapter.

Prototype

@Override
public void setAdapter(ListAdapter adapter) 

Source Link

Document

Sets the data behind this ListView.

Usage

From source file:com.brq.wallet.lt.activity.TradeHistoryFragment.java

@Override
public void onResume() {
    _myAdapter = new Wrapper(getActivity(), new ArrayList<TradeSession>());
    if (_ltManager.hasLocalTraderAccount()) {
        ListView list = (ListView) findViewById(R.id.lvRecentTrades);
        list.setAdapter(_myAdapter);
    }//from   www  .  ja va  2 s. com
    super.onResume();
}

From source file:com.fastbootmobile.encore.app.fragments.AutomixFragment.java

/**
 * {@inheritDoc}//from w w w  .ja  v  a 2s  . com
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_automix, container, false);
    final ListView lvBuckets = (ListView) rootView.findViewById(R.id.lvBuckets);
    mAdapter = new BucketAdapter();
    lvBuckets.setAdapter(mAdapter);

    lvBuckets.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            BucketAdapter.ViewHolder holder = (BucketAdapter.ViewHolder) view.getTag();
            holder.pbBucketSpinner.setVisibility(View.VISIBLE);

            if (mProgressToHide != null) {
                mProgressToHide.setVisibility(View.INVISIBLE);
            }

            mProgressToHide = holder.pbBucketSpinner;

            new Thread() {
                public void run() {
                    AutoMixManager.getDefault().startPlay(mAdapter.getItem(i));
                }
            }.start();
        }
    });

    mNoBucketTextView = (TextView) rootView.findViewById(R.id.txtNoBucket);

    return rootView;
}

From source file:com.cs411.trackallthethings.MyItems.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myitems);//w w w  . j  ava  2  s  . co m

    // bind the ArrayList of Item Objects to the Array Adapter
    // and then bind the Array Adapter to the ListView
    ListView myItemsFeed = (ListView) findViewById(R.id.myitemsfeed);
    myItemsAdapter = new ArrayAdapter<Item>(this, R.layout.item, myItems);
    myItemsFeed.setAdapter(myItemsAdapter);

    // fire up an AsyncTask to get the user's items
    //show the loading dialog
    loading = ProgressDialog.show(MyItems.this, "", "Getting your items...", true);
    getMyItems task = new getMyItems(MyItems.this,
            "http://www.trackallthethings.com/mobile-api/display_user_inventory_items.php");
    task.execute();

    Button back = (Button) findViewById(R.id.backfrommyitems);
    back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (myItemsAdapter != null)
                myItemsAdapter.clear();
            finish();
        }
    });
}

From source file:com.example.android.sunshine.app.RestoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // The ArrayAdapter will take data from a source and
    // use it to populate the ListView it's attached to.
    mRestoAdapter = new ArrayAdapter<String>(getActivity(), // The current context (this activity)
            R.layout.list_item_resto, // The name of the layout ID.
            R.id.list_item_resto_textview, // The ID of the textview to populate.
            new ArrayList<String>());

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
    listView.setAdapter(mRestoAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override/* w  w w  .  j ava 2s .co  m*/
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            String resto = mRestoAdapter.getItem(position);
            Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT, resto);
            startActivity(intent);
        }
    });

    return rootView;
}

From source file:br.com.PartoHumanizado.fragment.base.ResStringArrayListFragment.java

private void updateListView() {
    ListView listView = getListView();
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(listView.getContext(), R.layout.item_plano_de_parto,
            android.R.id.text1, stringArray);
    listView.setAdapter(adapter);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    listView.setItemsCanFocus(false);//  ww w .  ja v  a 2 s  .co m
}

From source file:com.dvdprime.mobile.android.ui.BbsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v;/*  w ww. j a v a2  s .c om*/
    topId = getArguments().getInt(DBConst.Bbs.TOP_ID);
    if (topId == 0) {
        mFavoriteAdapter = new FavoriteListAdapter(getActivity(), DBAdapter.getInstance().selectBbsList(topId));
        v = inflater.inflate(R.layout.fragment_favorite_list, container, false);
        ListView mFavoriteList = (ListView) v.findViewById(R.id.bbs_favorite_list);
        mFavoriteList.setOnItemClickListener(this);
        mFavoriteList.setEmptyView(v.findViewById(R.id.empty_favorite));
        mFavoriteList.setAdapter(mFavoriteAdapter);
    } else {
        mStickyAdapter = new StickyListAdapter(getActivity(), topId);
        v = inflater.inflate(R.layout.fragment_bbs_list, container, false);
        mStickyList = (StickyListHeadersListView) v.findViewById(R.id.bbs_list);
        mStickyList.setOnItemClickListener(this);
        mStickyList.setOnHeaderClickListener(this);
        mStickyList.setFastScrollEnabled(false);
        mStickyList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        mStickyList.setAdapter(mStickyAdapter);
    }

    return v;
}

From source file:com.acl.sunshine.app.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // The SimpleCursorAdapter will take data from the database through the
    // Loader and use it to populate the ListView it's attached to.
    mForecastAdapter = new SimpleCursorAdapter(getActivity(), R.layout.list_item_forecast, null,
            // the column names to use to fill the textviews
            new String[] { WeatherEntry.COLUMN_DATETEXT, WeatherEntry.COLUMN_SHORT_DESC,
                    WeatherEntry.COLUMN_MAX_TEMP, WeatherEntry.COLUMN_MIN_TEMP },
            // the textviews to fill with the data pulled from the columns above
            new int[] { R.id.list_item_date_textview, R.id.list_item_forecast_textview,
                    R.id.list_item_high_textview, R.id.list_item_low_textview },
            0);//from w ww. j av  a  2s .co  m

    mForecastAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            boolean isMetric = Utility.isMetric(getActivity());
            switch (columnIndex) {
            case COL_WEATHER_MAX_TEMP:
            case COL_WEATHER_MIN_TEMP: {
                // we have to do some formatting and possibly a conversion
                ((TextView) view).setText(Utility.formatTemperature(cursor.getDouble(columnIndex), isMetric));
                return true;
            }
            case COL_WEATHER_DATE: {
                String dateString = cursor.getString(columnIndex);
                TextView dateView = (TextView) view;
                dateView.setText(Utility.formatDate(dateString));
                return true;
            }
            }
            return false;
        }
    });

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
    listView.setAdapter(mForecastAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            Cursor cursor = mForecastAdapter.getCursor();
            if (cursor != null && cursor.moveToPosition(position)) {
                String dateString = Utility.formatDate(cursor.getString(COL_WEATHER_DATE));
                String weatherDescription = cursor.getString(COL_WEATHER_DESC);

                boolean isMetric = Utility.isMetric(getActivity());
                String high = Utility.formatTemperature(cursor.getDouble(COL_WEATHER_MAX_TEMP), isMetric);
                String low = Utility.formatTemperature(cursor.getDouble(COL_WEATHER_MIN_TEMP), isMetric);

                String detailString = String.format("%s - %s - %s/%s", dateString, weatherDescription, high,
                        low);

                Intent intent = new Intent(getActivity(), DetailActivity.class).putExtra(Intent.EXTRA_TEXT,
                        detailString);
                startActivity(intent);
            }
        }
    });

    return rootView;
}

From source file:com.darkoverlordofdata.malleus.HammerFragment.java

/**
 * Update the main view/*from  w ww . j  a  v  a2  s .  c o m*/
 *
 * @param inflater
 * @param container
 * @param savedInstanceState
 * @return
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_hammer, container, false);
    model = (DeviceModel) getArguments().getSerializable("model");

    /* Bind all of the controls */
    ListView list = (ListView) rootView.findViewById(R.id.list);
    analysis = (TextView) rootView.findViewById(R.id.analysis_value);
    status = (TextView) rootView.findViewById(R.id.status_value);

    StorageList adapter = new StorageList(getActivity(), model);

    list.setAdapter(adapter);

    analysis.setText(model.analysis());

    return rootView;
}

From source file:com.android.talkback.tutorial.TutorialMainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View view = inflater.inflate(R.layout.tutorial_main_fragment, container, false);

    ListView lessonListView = (ListView) view.findViewById(R.id.list);
    LessonsAdapter adapter = new LessonsAdapter(getActivity(), mTutorialController.getTutorial(),
            mLessonSelectedCallback);/*from w w  w  .j a v a 2  s  . c o  m*/
    lessonListView.setAdapter(adapter);
    mOffButton = (HoverTrackingButton) view.findViewById(R.id.offButton);
    mParentLayout = (HoverTrackingLinearLayout) view.findViewById(R.id.parentLayout);

    if (BuildCompat.isAtLeastN() && TalkBackService.getInstance() != null) {
        TalkBackService.getInstance().addEventListener(this);
    } else if (mOffButton != null) {
        mOffButton.setVisibility(View.GONE);
    }

    return view;
}

From source file:com.fallahpoor.infocenter.fragments.SimFragment.java

private void populateListView(ListView listView, TextView msgTextView) {

    if (isTelephonySupported() && isSimPresent()) {
        listView.setAdapter(new CustomArrayAdapter(getActivity(), getListItems()));
    } else {/*from   w  w  w.j  ava 2  s  . c  o m*/
        listView.setEmptyView(msgTextView);
    }

}