Results 1 to 5 of 5
  1. #1
    andreglud is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Question Wild errors apear!

    Hi foks

    I'm pretty much what most people would call a newbie. So dont blame me for bad questions. I'm trying to make a app, that can show diffrend websites. One for a forum. One for a donation page. And one for help. But I'm getting these strange syntax errors.

    See the file HERE

    Java Code:
    package com.example.tiberforum;
    
    import com.example.tiberforum.util.SystemUiHider;
    
    import android.annotation.TargetApi;
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Build;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.MotionEvent;
    import android.view.View;
    import android.widget.Button;
    
    public class TiberForum extends Activity {
    
    	Button button = (Button) findViewById(R.id.donate_button);
    	this.button.setOnClickListener(new OnClickListener() 
    		{
    			public void onClick(View v) {
    				String forumLink = "http://www.google.com";
    				Intent i = new Intent(Intent.ACTION_VIEW);
    				i.setData(Uri.parse(forumLink));
    				startActivity(i);
    			}
    		}
    	);
        /**
         * Whether or not the system UI should be auto-hidden after
         * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
         * 
         */
        private static final boolean AUTO_HIDE = true;
    
        /**
         * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
         * user interaction before hiding the system UI.
         */
        private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
    
        /**
         * If set, will toggle the system UI visibility upon interaction. Otherwise,
         * will show the system UI visibility upon interaction.
         */
        private static final boolean TOGGLE_ON_CLICK = true;
    
        /**
         * The flags to pass to {@link SystemUiHider#getInstance}.
         */
        private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
    
        /**
         * The instance of the {@link SystemUiHider} for this activity.
         */
        private SystemUiHider mSystemUiHider;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.activity_tiber_forum);
    
            final View controlsView = findViewById(R.id.fullscreen_content_controls);
            final View contentView = findViewById(R.id.fullscreen_content);
    
            // Set up an instance of SystemUiHider to control the system UI for
            // this activity.
            mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
            mSystemUiHider.setup();
            mSystemUiHider
                    .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
                        // Cached values.
                        int mControlsHeight;
                        int mShortAnimTime;
    
                        @Override
                        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
                        public void onVisibilityChange(boolean visible) {
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
                                // If the ViewPropertyAnimator API is available
                                // (Honeycomb MR2 and later), use it to animate the
                                // in-layout UI controls at the bottom of the
                                // screen.
                                if (mControlsHeight == 0) {
                                    mControlsHeight = controlsView.getHeight();
                                }
                                if (mShortAnimTime == 0) {
                                    mShortAnimTime = getResources().getInteger(
                                            android.R.integer.config_shortAnimTime);
                                }
                                controlsView.animate()
                                        .translationY(visible ? 0 : mControlsHeight)
                                        .setDuration(mShortAnimTime);
                            } else {
                                // If the ViewPropertyAnimator APIs aren't
                                // available, simply show or hide the in-layout UI
                                // controls.
                                controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
                            }
    
                            if (visible && AUTO_HIDE) {
                                // Schedule a hide().
                                delayedHide(AUTO_HIDE_DELAY_MILLIS);
                            }
                        }
                    });
    
            // Set up the user interaction to manually show or hide the system UI.
            contentView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (TOGGLE_ON_CLICK) {
                        mSystemUiHider.toggle();
                    } else {
                        mSystemUiHider.show();
                    }
                }
            });
    
            // Upon interacting with UI controls, delay any scheduled hide()
            // operations to prevent the jarring behavior of controls going away
            // while interacting with the UI.
            findViewById(R.id.donate_button).setOnTouchListener(mDelayHideTouchListener);
            findViewById(R.id.forum_button).setOnTouchListener(mDelayHideTouchListener);
            findViewById(R.id.forum_button).setOnTouchListener(mDelayHideTouchListener);
            
        }
    
        @Override
        protected void onPostCreate(Bundle savedInstanceState) {
            super.onPostCreate(savedInstanceState);
    
            // Trigger the initial hide() shortly after the activity has been
            // created, to briefly hint to the user that UI controls
            // are available.
            delayedHide(100);
        }
    
    
        /**
         * Touch listener to use for in-layout UI controls to delay hiding the
         * system UI. This is to prevent the jarring behavior of controls going away
         * while interacting with activity UI.
         */
        View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (AUTO_HIDE) {
                    delayedHide(AUTO_HIDE_DELAY_MILLIS);
                }
                return false;
            }
        };
    
        Handler mHideHandler = new Handler();
        Runnable mHideRunnable = new Runnable() {
            @Override
            public void run() {
                mSystemUiHider.hide();
            }
        };
    
        private void delayedHide(int delayMillis) {
            mHideHandler.removeCallbacks(mHideRunnable);
            mHideHandler.postDelayed(mHideRunnable, delayMillis);
        }
        
        
        
        private void viewForum( View view ){
        	
        	// Will open up the website
        	
        	String forumLink = "http://www.google.com";
        	
        	Intent i = new Intent(Intent.ACTION_VIEW);
        	i.setData(Uri.parse(forumLink));
        	startActivity(i);
        }
        
        private void viewDonation( View view ){
        	// Opens up donation view
        	
        	String donateLink = "http://www.google.com";
        	
        	Intent i = new Intent(Intent.ACTION_VIEW);
        	i.setData(Uri.parse(donateLink));
        	startActivity(i);
        	
        	
        }
        
        
    }
    Anyone got an idea of what the problem is?

    Errors at line:
    19, Syntax error on token ";", { expeced after this token

    59, Syntax error on token "(", expected
    Syntax error on token ")", expected
    Overrides android.app.Activity.onCreate

    111, Syntax error on token ")", expected
    Syntax error on token "(", expected
    Syntax error on token ")", expected
    Overrides android.app.Activity.onPostCreate
    Syntax error on token "(", expected

    164, Syntax error on token "(", expected
    Syntax error on token ")", expected

    171, Syntax error on token "(", expected
    Syntax error on token ")", expected

    182, Syntax error on token "(", expected
    Syntax error on token ")", expected



    I'm stuck..

    Eric
    Last edited by Norm; 11-16-2013 at 01:49 PM. Reason: Changed quote to code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: Wild errors apear!

    The compiler is finding errors in the source. Some of the error messages suggest a solution:
    { expeced after this token
    Did you look at that line and see about adding a {?
    The misspelling in the text of the above shows that the message was probably typed in, not copied and pasted.
    Try to copy and paste the full text of the error messages instead of typing them in.

    Also you need to copy the source file and paste it here so we can see it. No links.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    andreglud is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Re: Wild errors apear!

    The code is added. But how should I be able to copy the error, when it only appears when I have my mouse over the error icon?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: Wild errors apear!

    Sorry, I have no idea how to use your IDE. Some IDEs will write the error messages to a console where they can be copied to the clipboard.


    Did you read the error messages and follow the suggestions the compiler made?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,936
    Rep Power
    19

    Default Re: Wild errors apear!

    You can't have code (like the call to setOnClickListener) outside of a code block.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  2. Replies: 0
    Last Post: 10-29-2009, 09:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •