Guest User

Untitled

a guest
Nov 17th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public class EstadoActual extends Fragment {
  2.  
  3. // this controls work perfect
  4. @InjectView(R.id.txtWork1) AutoCompleteTextView txtWork1;
  5. @InjectView(R.id.txtWork2) EditText txtWork2;
  6.  
  7. // this controls are inside the viewstub,
  8. @InjectView(R.id.viewstub) ViewStub viewStub;
  9.  
  10. MyDynamicView myDynamicView;
  11. .. .. ...
  12. // class (inner in this example) that has stuff from your stub
  13. public class MyDynamicView {
  14. @InjectView(R.id.txtDontWork1) EditText txtDontWork1;
  15. @InjectView(R.id.txtDontWork1) EditText txtDontWork2;
  16. public MyDynamicView(View view) {
  17. Butterknife.inject(this, view);
  18. }
  19. }
  20.  
  21. @Override
  22. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  23. View rootView = inflater.inflate(R.layout.festadoactual, container, false);
  24. ButterKnife.inject(this, rootView);
  25. ... ..
  26. View viewFromStub = viewStub.inflate();
  27. myDynamicView = new MyDynamicView(viewFromStub); // this is the main point where you configure your view
  28. Fill();
  29. return rootView;
  30. }
  31.  
  32. private void Fill(){
  33. txtWork1.setText("Hello 1");
  34. txtWork2.setText("Hello 2");
  35.  
  36. myDynamicView.txtDontWork1.setText("Don't Work 1"); // This should work for you now
  37. myDynamicView.txtDontWork2.setText("Don't Work 2");
  38. }
Add Comment
Please, Sign In to add comment