Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. if(position == YOUR_MOVE_POSITION) {
  2.  
  3. // here hide ordinary elements, and set the ones you need to be visible
  4. }
  5.  
  6. public View getView(int position, View convertView, ViewGroup parent) {
  7.  
  8. final View v;
  9.  
  10. if(position == 1) { // here come instructions for 'header' no.1
  11. v = createViewFromResource(position, convertView, parent, mResource);
  12.  
  13. // the widget you want to show in header:
  14. ImageView yourMoveImage = (ImageView) v.findViewById(R.id.your_move);
  15.  
  16. // and here come widgets you don't want to show in headers:
  17. ImageView otherWidget = (ImageView) v.findViewById(R.id.other_widget);
  18.  
  19. // then you set the visibility:
  20. yourMoveImage.setVisibility(View.VISIBLE); // here is the key
  21. otherWidget.setVisibility(View.GONE); // it may also be View.INVISIBLE (look up the official docs for details)
  22.  
  23.  
  24. } else {
  25.  
  26. if(position == 5){ // here come instructions for 'header' no.1
  27.  
  28.  
  29. v = createViewFromResource(position, convertView, parent, mResource);
  30.  
  31. // the widget you want to show in header:
  32. ImageView theirMoveImage = (ImageView) v.findViewById(R.id.their_move);
  33.  
  34. // and here come widgets you don't want to show in headers:
  35. ImageView otherWidget = (ImageView) v.findViewById(R.id.other_widget);
  36.  
  37. // then you set the visibility:
  38. yourMoveImage.setVisibility(View.VISIBLE); // here is the key
  39. otherWidget.setVisibility(View.GONE); // it may also be View.INVISIBLE (look up the official docs for details)
  40.  
  41. } else {
  42.  
  43. // if it is the regular item, just show it as desribed in your XML:
  44. v = createViewFromResource(position, convertView, parent, mResource);
  45. }
  46. }
  47.  
  48. return v;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement