#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Trouble doing simple stuff


    This is driving me mad, trying to do some simple dialog creation and everytime i try to set an onclick listener i get fc here is code:
    Code:
    package com.example.joybot;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.webkit.WebView;
    import android.webkit.WebSettings;
    import android.widget.EditText;
    import android.widget.RadioButton;
    import android.widget.RadioButton.*;
    import android.widget.TextView;
    import android.widget.Button;
    import com.MobileAnarchy.Android.Widgets.Joystick.JoystickClickedListener;
    import com.MobileAnarchy.Android.Widgets.Joystick.JoystickMovedListener;
    import com.MobileAnarchy.Android.Widgets.Joystick.JoystickView;
    import android.app.ActionBar;
    import android.app.Dialog;
    import android.content.Context;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button.*;
    //import android.location.*;
    //import com.google.android.maps.*;
    import android.content.Intent;
    public class MainActivity extends Activity {
        ActionBar actbar;
        TextView txtX, txtY;
        JoystickView joystick;
        WebView mapper;
        int joyx, joyy;
        WebSettings webSettings;
        final Context context = this;
    
      
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
    
            joystick = (JoystickView)findViewById(R.id.joystick);
            mapper = (WebView)findViewById(R.id.webView);
            webSettings = mapper.getSettings();
            webSettings.setBuiltInZoomControls(true);
            mapper.loadUrl("(URL address blocked: See forum rules)");
            joystick.setOnJostickMovedListener(_listener);
    
    
        }
    
        private JoystickMovedListener _listener = new JoystickMovedListener() {
    
            @Override
            public void OnMoved(int pan, int tilt) {
                //txtX.setText(Integer.toString(pan));
                joyx=pan;
                joyy=tilt;
                //txtY.setText(Integer.toString(tilt));
            }
    
            @Override
            public void OnReleased() {
               // txtX.setText("released");
               // txtY.setText("released");
                joyx=0;
                joyy=0;
    
            }
    
            public void OnReturnedToCenter() {
               // txtX.setText("stopped");
                joyx=0;
                joyy=0;
                //txtY.setText("stopped");
            };
        };
    
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle item selection
            switch (item.getItemId()) {
                case R.id.action_settings:
                    final Dialog dialog = new Dialog(this);
                    dialog.setContentView(R.layout.activity__options);
                    dialog.setTitle("Options");
                    EditText svrAdd = (EditText)findViewById(R.id.editText);
                    EditText cmdPort = (EditText)findViewById(R.id.editText2);
                    EditText imgPort = (EditText)findViewById(R.id.editText3);
                    final RadioButton camOpt = (RadioButton)findViewById(R.id.radioButton);
                    final RadioButton imgOpt = (RadioButton)findViewById(R.id.radioButton2);
                    camOpt.setOnClickListener(new View.OnClickListener(){
                        @Override
                        public void onClick(View view) {
                            imgOpt.setChecked(false);
                        }
                    });
                    imgOpt.setOnClickListener(new View.OnClickListener(){
                        @Override
                        public void onClick(View view) {
                            camOpt.setChecked(false);
                        }
                    });
                    camOpt.setChecked(true);
                    imgOpt.setChecked(false);
    
                 return true;
                }
            return false;
    
            }
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Talking fixed


    Ended up working it out myself, i needed to use:
    Code:
    Button saveBut = (Button)dialog.findViewById(R.id.button2);
    
    and not
    
    Button saveBut = (Button)findViewById(R.id.button2);

IMN logo majestic logo threadwatch logo seochat tools logo