简体   繁体   English

Android Scrollview:如何选择要返回的Scrollview?

[英]Android Scrollview: How to select the Scrollview to return to?

I'm working on an android app that's working with Scrollviews. 我正在使用与Scrollviews一起工作的android应用程序。 On each scrollview are two buttons, info and gallery. 每个滚动视图上都有两个按钮,信息和图库。 When the gallery button is clicked it takes you to a gallery xml. 单击图库按钮后,会将您带到图库xml。 When the info button is clicked it takes you back to the info page. 单击信息按钮后,您将返回到信息页面。

The problem is, when the info button is clicked it brings you back to the info page on the first scrollview, even if you are on the third or fourth scrollview. 问题是,当单击信息按钮时,即使您在第三或第四滚动视图上,它也带您回到第一个滚动视图上的信息页面。

public void onClick(View v) {      
//gallery button clicked, go to gallery screen

setContentView(R.layout.dunnanoirgall);
final Button gallery3 =(Button)findViewById(R.id.btnGallery15);
gallery3.setPressed(true);

//info button
Button infoBtn =(Button)findViewById(R.id.btnInfo15);
infoBtn.setOnClickListener(new View.OnClickListener() {

            **public void onClick(View v) {      
            //info button clicked, go to info screen
            setContentView(R.layout.islandtours);
            //setScrollView(R.id.scrollView2);**

            }
});

What I'm looking for is to get a method setScrollView (shown within the **) that allows me to return to the info page of the scrollview I was on, rather than the first scrollview. 我正在寻找的是获得一个setScrollView方法(显示在**中),该方法使我可以返回到所使用的滚动视图的信息页面,而不是第一个滚动视图。

I find your question hard to understand. 我觉得你的问题很难理解。 Do you have several scrollviews in one activity or in different activities ? 您在一个活动或不同活动中有几个滚动视图吗? And why does a click on the info button brings you "back" somewhere ? 为什么单击“信息”按钮会带您“返回”某处?

So let me try and get the info right: 因此,让我尝试正确获取信息:

You have 4 different layouts each with a scrollview, and two buttons. 您有4种不同的布局,每个布局都有一个滚动视图和两个按钮。 One to launch a gallery and another to launch an info page. 一个启动画廊,另一个启动信息页面。

Its hard to decipher exactly whats going on, but ill try my best. 很难准确解释发生了什么,但是我会尽力而为。

From what I see from your code you set the contentview on button push, but you aren't changing the actually text. 根据我从您的代码中看到的内容,您可以在按钮按下时设置contentview,但是您并没有更改实际的文本。 Your probably not changing your information. 您可能不会更改您的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM