I want to know the correct control method such as layout button and text included in the view phaser

Asked 2 years ago, Updated 2 years ago, 24 views

Using a viewpager in Mainactivity (aa, bb, cc).You are showing xml.

If the button declared in aa.xml
public void onCreate(Bundle savedInstanceState)

{ super.onCreate(savedInstanceState);

    setContentView(R.layout.aa);

} I tried to refer to the class that declared that it was dead, so I looked for a way 

at Mainactivity.class private View.OnClickListener mPagerListener = new View.OnClickListener() { @Override public void onClick(View v) { What to do when you click a button } };

This way, the button gets a click event.

If you have any questions (aaa, bb, cc) layout buttons, text views, etc. included in the view phaser If you want to operate the event, you can only declare it in the Mainactivity.class The code becomes too messy.

Do you know how to use the general method, i.e. declare a .class for each layout? Is there a way to operate?

android

2022-09-22 21:09

2 Answers

Look for an example of displaying fragments instead of .xml in the viewpager.


2022-09-22 21:09

http://itpangpang.xyz/286 I think this example might be a little helpful, so I'm going to upload it.


2022-09-22 21:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.