Search code examples
androidlayoutbuttononclickpreference

layout.xml file has button, I can't figure out how to link each button to open a new preference screen


layout.xml file has button, I can't figure out how to link each button to open a new preference screen.

looking to rearrange my app, currently it's all preference screen, wantedto change it to revamp the UI a little to have buttons on the main page, and each one will open a new preference screen that I already have set up, any advice, I can't seem to figure out how to have it just open that already made preference scree.


Solution

  • For something like going to another screen from a home screen, i'll do somethingl ike this:

    ImageView floor = (ImageView)findViewById(R.id.floor);
    floor.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {   
            Intent intent = new Intent(Home.this, WheelDemo.class);
            startActivity(intent);
        }
    });
    

    floor is a button image, it starts the new activity, WheelDemo when it is clicked on and goes to a new screen for that activity. Jut make sure each activity is registered in your manifest.