I am trying to create a very simple application (part of my learning program), vertically oriented, with an EditText at the top that receives a URL, and two buttons side by side just below that say "Get Image" or "Get Text" depending on the URL typed in (.html vs. .png, for example). The resulting elements may be later scavanged for use in a real app.
I know that ScrollView can have only one child. Conceptually, I want the rest of the screen to be a vertically oriented content region for displaying either the text (TextView) of the URL and "Get Text" was clicked or the image (ImageView) in the case where it was an image and "Get Image" was clicked.
I tried to do this (pseudocode) in main.xml:
<LinearLayout>
<EditText /> --where to type the URL
<Button /> --click to treat URL as text
<Button /> --click to treat URL as image
<FrameLayout> --(used to be ScrollView)
<LinearLayout>
<TextView /> --content region occupied by either text
<ImageView /> --or an image (but not both)
</LinearLayout>
</FrameLayout>
</LinearLayout>
in order not to violate the single-child requirement. However, this doesn't work and for now I'm not finding any sample out there that clues me in to how best to accomplish this. The last complaint I got while debugging was:
Caused by: java.lang.ClassCastException: android.widget.TextView
If anyone has the time and patience to steer me in some useful direction, I'd greatly appreciate it.
Thanks,
Russ Bateman