Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

zarah hafeez
zarah hafeez
317 Points

I have created an app which shows around 40 qoutes by pressing next button

I have created an app which shows around 40 qoutes by pressing next button but now I want my PREV button to be functional & I'm not getting it's way as I'm new to android. Below is my app code:

Main Activity:

package com.example.i7.fun_quotes;

import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.style.BackgroundColorSpan; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast;

import java.util.Random;

public class MainActivity extends AppCompatActivity { public static final String TAG = "FunFactActivity"; private FunObject mFunObject = new FunObject(); private TextView mFunTextView; private Button mFunButtonView; //private Button mPrevbutton; private RelativeLayout mRelativeLayout; private FunColor mFunColor = new FunColor();

@Override
protected void onCreate(Bundle savedInstanceState) {



    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mFunTextView = (TextView) findViewById(R.id.FunTextView);
    mFunButtonView = (Button) findViewById(R.id.FunButtonView);
   // mPrevbutton = (Button) findViewById(R.id.Prevbutton);
    mRelativeLayout= (RelativeLayout) findViewById(R.id.Relativelayout);


    View.OnClickListener Listner = new View.OnClickListener(){

        @Override
        public void onClick(View v) {

            String fact = mFunObject.GetFact();
            int colorAsInt = mFunColor.GetColor();

            mFunTextView.setText(fact);
            mRelativeLayout.setBackgroundColor(colorAsInt);

        }
    };

    mFunButtonView.setOnClickListener(Listner);
    //mPrevbutton.setOnClickListener();

// Toast.makeText(MainActivity.this, "MY FUN FACTS APP", Toast.LENGTH_SHORT).show(); Log.d("TAG","I'm standing here");

}

}