Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.kpb.mmw;
- import android.os.Bundle;
- import android.support.v4.app.Fragment;
- import android.support.v4.app.FragmentActivity;
- import android.support.v4.app.FragmentManager;
- import android.support.v4.app.FragmentTransaction;
- import android.view.LayoutInflater;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.Button;
- public class SettingsForm extends FragmentActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_settings_form);
- if (savedInstanceState == null) {
- //FragmentManager fragmentManager = getFragmentManager();
- FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- SettingFragment_Page1 fragment = new SettingFragment_Page1();
- fragmentTransaction.add(R.id.container, fragment, "tag");
- fragmentTransaction.commit();
- fragmentManager.executePendingTransactions();
- SettingFragment_Page1 fra = (SettingFragment_Page1) getSupportFragmentManager().findFragmentByTag("tag");
- fra.SetText("aaaa");
- //Log.d("I: ", fra.GetText());
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.settings_form, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- /**
- * A SettingFragment fragment containing a simple view.
- */
- public static class SettingFragment_Page1 extends Fragment {
- View rootView;
- private Button mButton1;
- public SettingFragment_Page1() {
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- rootView = inflater.inflate(R.layout.fragment_settings_form_page1, container, false);
- mButton1 = (Button) rootView.findViewById(R.id.button);
- return rootView;
- }
- public void SetText(String aa){
- mButton1 = (Button) rootView.findViewById(R.id.button);
- mButton1.setText(aa);
- }
- public String GetText(){
- return Double.toString(Math.random());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement