Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <LinearLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical">
  6.  
  7. <ListView
  8. android:id="@id/android:list"
  9. android:drawSelectorOnTop="false"
  10. android:layout_weight="1"
  11. android:layout_height="0dp"
  12. android:layout_width="fill_parent">
  13. </ListView>
  14. </LinearLayout>
  15.  
  16. public class PublicTradeListFragment extends ListFragment
  17. {
  18. private String trades[];
  19.  
  20. public PublicTradeListFragment()
  21. {
  22. trades = new String [] {
  23. "Trade ?",
  24. "Give up ?",
  25. "Trade again?"
  26. };
  27. }
  28.  
  29. @Override
  30. public void onCreate(Bundle savedInstanceState){
  31. super.onCreate(savedInstanceState);
  32. ListAdapter listAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,trades);
  33. setListAdapter(listAdapter);
  34. }
  35.  
  36. @Override
  37. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
  38. {
  39. return inflater.inflate(R.layout.list_fragment,container,false);
  40. }
  41.  
  42. @Override
  43. public void onListItemClick(ListView list, View v, int position, long id) {
  44.  
  45. Toast.makeText(getActivity(), getListView().getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement