Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="horizontal"
  6. android:descendantFocusability="blocksDescendants">
  7.  
  8. <TextView
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:id="@+id/station_name"
  12. android:padding="10dp"
  13. android:textColor="#eee345"
  14. android:textAppearance="?android:textAppearanceLarge"
  15. />
  16.  
  17. <ImageButton android:id="@+id/favorite"
  18. android:layout_width="wrap_content"
  19. android:layout_height="fill_parent"
  20. android:src="@drawable/start"
  21. android:background="#00ffffff"
  22. />
  23.  
  24.  
  25. </LinearLayout>
  26.  
  27. public class Fragmentone extends Fragment{
  28.  
  29. ArrayList<String> name;
  30. boolean isPressed=false;
  31.  
  32. @Nullable
  33. @Override
  34. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  35. View view = inflater.inflate(R.layout.fragment_one, container, false);
  36. name=new ArrayList<String>();
  37. name.add("First Station");
  38. name.add("Second Station");
  39.  
  40.  
  41. ListView listView = (ListView) view.findViewById(R.id.list_view);
  42. listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  43. @Override
  44. public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  45. String item = (String) parent.getItemAtPosition(position);
  46. Toast.makeText(getActivity(), "Item : " + item, Toast.LENGTH_SHORT).show();
  47. }
  48. });
  49.  
  50. ArrayAdapter arrayAdapter =new ArrayAdapter(getActivity(),R.layout.row_layout,R.id.station_name,name);
  51. listView.setAdapter(arrayAdapter);
  52.  
  53.  
  54.  
  55. return view;
  56. }
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement