Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.kpb.mmw;
- import android.app.Fragment;
- import android.app.FragmentManager;
- import android.app.FragmentTransaction;
- import android.os.Bundle;
- import android.support.v4.app.FragmentActivity;
- import android.util.Log;
- 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 implements View.OnClickListener{
- @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();
- SettingFragment_Page1 fra = (SettingFragment_Page1) getFragmentManager().findFragmentByTag("tag");
- fra.setButtonText("aaaa");
- Log.d("I: ", fra.getButtonText());
- }
- }
- @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);
- }
- @Override
- public void onClick(View v) {
- Functions.ShowMessage(Integer.toString(v.getId()),this);
- }
- /**
- * A SettingFragment fragment containing a simple view.
- */
- public static class SettingFragment_Page1 extends Fragment{
- private Button mButton1;
- public SettingFragment_Page1() {
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_settings_form_page1, container, false);
- mButton1 = (Button) rootView.findViewById(R.id.button);
- return rootView;
- }
- public void setButtonText(String text){
- mButton1.setText(text);
- }
- public String getButtonText(){
- return mButton1.getText().toString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement