Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package com.geldapp;
  2.  
  3.  
  4. import android.os.Bundle;
  5. import android.support.annotation.Nullable;
  6. import android.support.v4.app.Fragment;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.view.View.OnClickListener;
  11. import android.widget.Button;
  12. import android.widget.EditText;
  13. import android.widget.TextView;
  14.  
  15. public class FragmentA extends Fragment {
  16. Button bt1;
  17. TextView tv1;
  18. TextView tv2;
  19. EditText et1;
  20.  
  21. @Override
  22. public View onCreateView(LayoutInflater inflater,
  23. @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  24. View rootview = inflater.inflate(R.layout.fragmenta_layout, container,false);
  25. tv1 = (TextView) rootview.findViewById(R.id.textView1);
  26. tv2 = (TextView) rootview.findViewById(R.id.textView2);
  27. bt1 = (Button) rootview.findViewById(R.id.button1);
  28. et1 = (EditText) rootview.findViewById(R.id.input);
  29.  
  30.  
  31.  
  32. bt1.setOnClickListener(new OnClickListener() {
  33.  
  34. @Override
  35. public void onClick(View v) {
  36. // TODO Auto-generated method stub
  37. EditText input = (EditText) rootview.findViewById(R.id.input); // Lese Wert aus Text
  38. float wert = Float.valueOf(input.getText().toString()); // Wandle Wert in float
  39. tv2.setText(String.valueOf(wert));
  40. }
  41.  
  42. });
  43.  
  44.  
  45.  
  46.  
  47. return rootview;
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement