Example usage for android.widget ListView ListView

List of usage examples for android.widget ListView ListView

Introduction

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

Prototype

public ListView(Context context) 

Source Link

Usage

From source file:com.skubit.android.example.SkusFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListView listView = new ListView(getActivity());
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override//  w ww. ja  v  a  2 s  .  co m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Map<String, String> map = (Map<String, String>) parent.getItemAtPosition(position);
            ((MainActivity) getActivity()).makePurchase(map);
        }

    });

    ((MainActivity) getActivity()).fetchSkus(listView);
    return listView;
}

From source file:com.commonsware.cwac.masterdetail.MasterDetailStrategy.java

ListView buildListView(Activity host) {
    ListView result = new ListView(host);

    result.setId(android.R.id.list);/*from w  w w.j  av a 2 s  .  c  o  m*/
    result.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    return (result);
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.NetworkServiceDiscoveryProfileFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });
    final Context context = getActivity();

    FrameLayout lframe = new FrameLayout(context);

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);/*w  w w  . j  a v a2 s .c  o  m*/
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    mListView = (ListView) lframe.findViewById(android.R.id.list);
    mListView.setAdapter(new ArrayAdapter<SmartDevice>(getActivity(), android.R.layout.simple_list_item_1));

    (new ServiceDiscoveryTask()).execute();

    mLogger.exiting(getClass().getName(), "onCreateView", mListView);
    return lframe;
}

From source file:at.tomtasche.reader.ui.widget.RecentDocumentDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle(R.string.dialog_recent_title);
    builder.setCancelable(true);//  w  w w .  ja  va2  s .  c o  m

    TextView emptyView = new TextView(getActivity());
    emptyView.setText(R.string.dialog_loading_title);

    listView = new ListView(getActivity());
    listView.setEmptyView(emptyView);
    listView.setOnItemClickListener(this);
    listView.setOnItemLongClickListener(this);

    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[0]);
    listView.setAdapter(adapter);

    builder.setView(listView);

    setCancelable(true);

    items = new HashMap<String, String>();

    loadRecentDocuments();

    listView.setEmptyView(emptyView);

    return builder.create();
}

From source file:com.github.chilinh.androidformbuilder.MainFragment.java

@Nullable
@Override//from ww  w  . j  a  v  a 2  s . com
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ListView listView = new ListView(container.getContext());

    listView.setAdapter(new ArrayAdapter<>(container.getContext(), android.R.layout.simple_list_item_1,
            new String[] { "Dialog Form", "Fragment" }));
    listView.setOnItemClickListener((parent, view, position, id) -> {
        switch (position) {
        case 0:
            showDialog();
            break;
        case 1:
            showFragment();
            break;
        }
    });
    return listView;
}

From source file:net.saga.aeroconf.app.ui.fragment.ScheduleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = new ListView(inflater.getContext());
    view.setAdapter(adapter);//w w  w  . j av a2 s . c o  m

    view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (adapter.getItem(position) instanceof Schedule) {
                Schedule item = (Schedule) adapter.getItem(position);
            }
        }
    });

    return view;
}

From source file:com.dpcsoftware.mn.EditGroups.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = (App) getApplication();// w w w  .j a  v a 2 s.  c  o m
    lv = new ListView(EditGroups.this);

    renderGroups();

    getSupportActionBar().setTitle(R.string.editgroups_c1);
}

From source file:com.daiv.android.twitter.settings.SettingsLinkDrawerClickListener.java

@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {

    Intent intent;// ww w .  jav a2  s.  c  om

    final int mPos = position;

    if (mPos < 2) { // one of the settings pages
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mDrawerLayout.closeDrawer(Gravity.START);
            }
        }, 300);

        viewPager.setCurrentItem(mPos + 7, true);
    } else if (mPos == 2) { // changelog

        final ListView list = new ListView(context);
        list.setDividerHeight(0);

        new AsyncTask<Spanned[], Void, Spanned[]>() {
            @Override
            public Spanned[] doInBackground(Spanned[]... params) {
                return XmlChangelogUtils.parse(context);
            }

            @Override
            public void onPostExecute(Spanned[] result) {
                list.setAdapter(new ChangelogAdapter(context, result));
            }
        }.execute();

        new AlertDialog.Builder(context).setTitle(R.string.changelog).setView(list)
                .setPositiveButton(R.string.ok, null).show();

    } else if (mPos == 3) { // rate it option
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);

                try {
                    context.startActivity(goToMarket);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show();
                }
            }
        }, 200);

    }
}

From source file:com.pendtium.quran.fragments.QuranFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout fl = (FrameLayout) super.onCreateView(inflater, container, savedInstanceState);
    ListView listView = new ListView(getActivity());
    listView.setLayoutParams(params);/* ww w .  ja v  a2 s  .  c om*/
    listView.setBackgroundResource(R.drawable.background_card);
    //      setListSurat();
    //      adapter = getAdapter();
    //      adapter.updateList(listAyat);
    //      listView.setAdapter(adapter);
    listView.setOnItemClickListener(getOnItemClickListener());
    fl.addView(listView);
    //      if (listAyat.isEmpty()) {
    //         updateContent();
    //      }
    return fl;
}

From source file:de.escoand.readdaily.AbstractContentFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
        @Nullable final Bundle savedInstanceState) {
    adapter = new SimpleCursorAdapter(getContext(), layout, null, from, to, 0);
    adapter.setViewBinder(this);
    adapter.changeCursor(cursor);/*from  w ww . jav  a  2 s  .c  o m*/

    if (savedInstanceState != null)
        onDateSelected(Database.getDateFromInt(savedInstanceState.getInt(STATE_DATE)));

    ListView list = new ListView(getContext());
    list.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    list.setAdapter(adapter);

    return list;
}