Android Open Source - android-robot-control-app Two Wheel Toy Fragment






From Project

Back to project page android-robot-control-app.

License

The source code is released under:

GNU General Public License

If you think the Android project android-robot-control-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package will.st.bluetooth.robot.controller;
/*w  w w  . j ava  2 s.c  o m*/
import will.st.bluetooth.robotcontroller.R;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

public class TwoWheelToyFragment extends Fragment {
  int fragVal;
  ImageButton twoWheelToyButton;

  static TwoWheelToyFragment init(int val) {
    TwoWheelToyFragment twoWheelToyFrag = new TwoWheelToyFragment();
    // Supply val input as an argument.
    Bundle args = new Bundle();
    args.putInt("val", val);
    twoWheelToyFrag.setArguments(args);
    return twoWheelToyFrag;
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    fragVal = getArguments() != null ? getArguments().getInt("val") : 1;
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View layoutView = inflater.inflate(R.layout.fragment_two_wheel_toy, container,
        false);
    twoWheelToyButton = (ImageButton) layoutView.findViewById(R.id.two_wheel_toy_button);
    twoWheelToyButton.setOnClickListener(new TwoWheelToyButtonListener());
    return layoutView;
  }
  
  class TwoWheelToyButtonListener implements OnClickListener {
    public void onClick(View v) {

      Intent controllerActivityIntent = new Intent(
          getActivity().getApplicationContext(), ControllerActivity.class);
      // This will inform the next activity which ControllerFragment to
      // use.
      controllerActivityIntent.putExtra(ToyMenuActivity.SELECTED_CONTROLLER_FRAGMENT,
          "XControllerFragment");
      startActivity(controllerActivityIntent);
    }
  }
}




Java Source Code List

will.st.bluetooth.robot.controller.BtConnectFragment.java
will.st.bluetooth.robot.controller.ConnectionFailedException.java
will.st.bluetooth.robot.controller.ControllerActivity.java
will.st.bluetooth.robot.controller.CrabToyFragment.java
will.st.bluetooth.robot.controller.MainMenuActivity.java
will.st.bluetooth.robot.controller.ToyMenuActivity.java
will.st.bluetooth.robot.controller.TwoWheelToyFragment.java
will.st.bluetooth.robot.controller.controllers.ControllerFragmentFactory.java
will.st.bluetooth.robot.controller.controllers.ControllerFragment.java
will.st.bluetooth.robot.controller.controllers.XControllerFragment.java