Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. for (int i = 0; i < stringObjectsDetails.length; i++) {
  2. stringObjectsDetails[i] = objectsDetails.get(i).getTitle();
  3. }
  4.  
  5. ListView listView = (ListView) findViewById(R.id.list_objects);
  6. ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
  7. R.layout.object_item, stringObjectsDetails);
  8. listView.setAdapter(adapter);
  9.  
  10. activity_xxx.xml (1)
  11.  
  12. <?xml version="1.0" encoding="utf-8"?>
  13. <FrameLayout
  14. xmlns:android="http://schemas.android.com/apk/res/android"
  15. xmlns:app="http://schemas.android.com/apk/res-auto"
  16. xmlns:tools="http://schemas.android.com/tools"
  17. android:layout_width="match_parent"
  18. android:layout_height="match_parent"
  19. android:orientation="vertical">
  20.  
  21. <android.support.v7.widget.RecyclerView
  22. android:id="@+id/list_objects_recycler"
  23. android:layout_width="match_parent"
  24. android:layout_height="match_parent"
  25. app:layoutManager="android.support.v7.widget.LinearLayoutManager"
  26. tools:listitem="@layout/object_item"/>
  27. </FrameLayout>
  28.  
  29.  
  30.  
  31. object_item.xml (2)
  32.  
  33. <?xml version="1.0" encoding="utf-8"?>
  34. <android.support.v7.widget.CardView
  35. xmlns:android="http://schemas.android.com/apk/res/android"
  36. xmlns:app="http://schemas.android.com/apk/res-auto"
  37. xmlns:tools="http://schemas.android.com/tools"
  38. android:layout_width="match_parent"
  39. android:layout_height="wrap_content"
  40. android:layout_margin="8dp">
  41.  
  42. <LinearLayout
  43. android:orientation="horizontal"
  44. android:layout_width="match_parent"
  45. android:layout_height="match_parent">
  46.  
  47. <ImageView
  48. android:layout_width="wrap_content"
  49. android:layout_height="wrap_content"
  50. app:srcCompat="@mipmap/ic_launcher"
  51. android:id="@+id/object_logo"
  52. />
  53.  
  54. <TextView
  55. android:id="@+id/object_title"
  56. android:layout_width="wrap_content"
  57. android:layout_height="match_parent"
  58. android:padding="8dp"
  59. tools:text="@string/title_object_string"
  60. android:layout_weight="1"
  61. />
  62. </LinearLayout>
  63.  
  64.  
  65. </android.support.v7.widget.CardView>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement