List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.android.talkbacktests.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { final View view = inflater.inflate(R.layout.fragment_main, container, false); final ListView testListView = (ListView) view.findViewById(R.id.list); testListView.setAdapter(mAdapter); return view;/*from www .jav a2s .com*/ }
From source file:com.commonsware.android.drawer.simple.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (getFragmentManager().findFragmentById(R.id.content) == null) { showLorem();/* w ww . j a v a2s .com*/ } ListView drawer = (ListView) findViewById(R.id.drawer); drawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_row, getResources().getStringArray(R.array.drawer_rows))); drawer.setOnItemClickListener(this); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); drawerLayout.setDrawerListener(toggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); }
From source file:co.adrianblan.noraoke.SongLibraryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_song_library, container, false); ListView listView = (ListView) rootView.findViewById(R.id.library_song_list); listView.setAdapter(new SongAdapter(getActivity())); //We add a listener to each item in the list //When pressed, opens info page to backstreet boys listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w .ja v a 2 s. c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(getActivity(), SongInfoActivity.class); getActivity().startActivity(intent); } }); final Context context = this.getActivity(); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.library_fab); fab.attachToListView(listView); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(context).setTitle("Sort songs").setMessage( "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.") .setNegativeButton("Cancel", null).setPositiveButton("Sort", null).show(); } }); ViewCompat.setElevation(rootView, 50); return rootView; }
From source file:com.fallahpoor.infocenter.fragments.RamFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_others, container, false); ListView listView = (ListView) view.findViewById(R.id.listView); listView.setAdapter(new CustomArrayAdapter(getActivity(), getListItems())); return view;//from ww w .j av a 2 s .c o m }
From source file:com.enadein.carlogbook.ui.NotificationFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); notificationAdapter = new NotificationAdapter(getActivity(), null); ListView notifyListView = (ListView) view.findViewById(R.id.list); notifyListView.setAdapter(notificationAdapter); notifyListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//ww w .j a v a 2 s.com public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { getMediator().showEditNotifcation(id); // CommonUtils.createNotify(getActivity(),id); } }); view.findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getMediator().showAddNotification(); } }); }
From source file:com.example.android.mobileperf.render.ChatsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Create a list of chats and populate it with hardcoded data. ArrayList<Chat> chats = new ArrayList<Chat>(); populateChats(chats);//w w w . j ava2 s. co m // Create the adapter that provides values to the UI Widgets. ChatAdapter adapter = new ChatAdapter(getActivity(), chats); View rootView = inflater.inflate(R.layout.fragment_chats, container, false); // Find the ListView that holds all the chat messages and attach it to the adapter, ListView listView = (ListView) rootView.findViewById(R.id.listview_chats); listView.setAdapter(adapter); return rootView; }
From source file:com.enadein.carlogbook.ui.MyCarsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); carAdapter = new CarAdapter(getActivity(), null); ListView carListView = (ListView) view.findViewById(R.id.list); carListView.setAdapter(carAdapter); carListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w. j av a2s . com public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { getMediator().showViewCar(id); } }); carListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { DBUtils.selectActivCar(getActivity().getContentResolver(), id); getMediator().getUnitFacade().reload(id); return true; } }); view.findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getMediator().showAddCar(); } }); getLoaderManager().initLoader(CarLogbook.LoaderDesc.CAR_ID, null, this); }
From source file:br.pro.menotti.opus.pt.DisplayChapters.java
@Override protected void onCreate(Bundle savedInstanceState) { SQLiteHelper db;//from w w w . jav a 2s.co m super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); book = intent.getIntExtra("book", 0); db = new SQLiteHelper(this); db.openDataBase(); List<Chapter> chapters = new ArrayList<Chapter>(); chapters = db.getChapters(book); setTitle(getString(R.string.display_chapters) + ": " + db.getBook(book)); db.close(); ListView lv = (ListView) findViewById(android.R.id.list); lv.setAdapter(new CustomAdapter<Chapter>(this, android.R.layout.simple_list_item_1, chapters)); Toast.makeText(getApplicationContext(), (getString(R.string.display_aleatory_point)), Toast.LENGTH_SHORT) .show(); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { showPoints(book, (int) id); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { SQLiteHelper db; db = new SQLiteHelper(getBaseContext()); db.openDataBase(); BookPoint bp = db.getBookPoint(book, position); DialogFragment newFragment = new DialogPoint(bp); newFragment.show(getSupportFragmentManager(), bp.toString()); db.close(); return true; } }); }
From source file:MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView listSigns = getListView(); ArrayAdapter<Zodiac> listAdapter = new ArrayAdapter<Zodiac>(this, android.R.layout.simple_list_item_1, Zodiac.signs);//from w ww . j a v a 2 s . co m listSigns.setAdapter(listAdapter); }
From source file:com.fallahpoor.infocenter.fragments.AndroidFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_others, container, false); ListView listView = (ListView) view.findViewById(R.id.listView); listView.setAdapter(new CustomArrayAdapter(getActivity(), getListItems())); return view;/*from w w w. j a v a 2 s.c o m*/ }