Android Studio - Scrolling page with multiple textviews - java

To help with the explanation of what I'm trying to do I'll use the example of twitter (RSS feed concept).
A single activity with multiple bodies of text that all move simultaneously on the page.
I understand how to use a scroll view, however this only allows for one scrolling body of text. What I'm seeking is all textviews to scroll collectively as I move up or down the page.
Thanks,
Aaron

This behaviour what you described is exactly the function of a ListView . If you never used it before, take a look at this tutorial for example: http://androidexample.com/Create_A_Simple_Listview_-_Android_Example/index.php?view=article_discription&aid=65&aaid=90

Related

What Box like view should I use?

I'm trying to create an app using Android Studio, and I want to use some type of expandable box, where I'll have an indefinite number shown like in a stack, and when clicking on the left side icon, the selected box opens up to show more info.
The basic idea of what I'm searching for:
Would anyone know about something like that??
Thanks in advance.
If I understand it well, what you're looking for is a recyclerview (for the indefinite number of row) and an accordion widget to open close your content.
I will suggest your to look at these projects:
https://github.com/hgDendi/ExpandableRecyclerView
https://android.jlelse.eu/get-expandable-recyclerview-in-a-simple-way-8946046b4573
which present all requirements you need.
And here is an similar question/answer : https://stackoverflow.com/a/10313432/6809926
The google search I made : android accordion recyclerview example.

How to create an Accordion Menu?

I want to create Menu like this. Tap on any Item it will open Submenu with Items
I don't think there exists a library which will allow you to do this. (I may be wrong).
But according to me the best possible way to achieve this would be to use two tableViews placed next to each other and updating the the data for the second tableView on didSelectRow of the first tableView. You would have manage a few complexities but it is achievable.
If you only have 2 level of details in your menu, you could also use one tableView, show the 1st level elements in the section header, and create rows on section header click (using a button or tap) for the second level elements.
Edit:
My answer mentions some iOS naming conventions. Because it was originally asked for iOS with tag iOS and swift. I decided not change the original answer because the core concept of achieving this should be similar on both platforms.
Anyways, I think you can still do same stuff for android, just use list view where I mentioned tableView

Inline Clickable List Layout in Android

I want to create a sort of inline list of clickable text blocks in Android Studio. Below is the closest image I could find to the effect I would like. How would I achieve such an effect?
The information shown will be just a string, however clicking on this will take the user to another activity. It would be good if the text blocks also had a background, by the looks of it this app uses an image as the background, which should be fairly easy to set if the list is made from text views. I just don't know how to make a list with variable length inline objects.
See here: https://github.com/google/flexbox-layout
What I was looking for was specifically a horiztonal, wrapping, inline list.

Multi-page application with corresponding pictures and text

I'm new to Java and Android. I have been trying for the past week to make an app for my phone. The app consists of 4 pages, which are diagrammed below:
Page 1: Contains a picture taking up the size of the screen. If I click on the picture it needs to go to "page 2".
Page 2: Consists of an icon on the left (say the flag for instance) followed by a text field (eg. USA). When "USA" strip is clicked it needs to go to page 3.
Page 3: Consists of text, picture and then more text from a string. This page needs to correspond to the strip clicked on in page 2 ("USA" in this example). There are also two buttons at the bottom of "page 3" and "page 4" which when pressed need to go to the corresponding page numbers.
Page 4: This page is displayed if the "More" button is pressed on "page 3".
I would like this phone to work on a minimum Android 2.2 or 2.3. All logos, pictures and string texts need to be locally available (resources folder) and not website based. I have tried all sorts of combinations of ListView's and buttons with OnClickListener's as well as toast screens. My limited knowledge of programming is frustrating.
My question is if there is a template around which will help me out with this app? Or if there are any web resources.
In Android, individual "pages" or "screens" can be implemented as Activitys. You need to extend the Activity class and add the components that you wish to display. Most of the layout can be done in an XML file. I strongly suggest that you google for a tutorial that illustrates the basics of Android programming. From there, you can start by creating an app with two pages. And then just keep adding a little bit at a time until you get the complete app that you want.
There some easy ways to do this. If you want to be backwards compatible to SDK 8 you can do this in two ways. You can use Fragments or Activities for each layout. If you implement fragments, I suggest reading http://developer.android.com/guide/components/fragments.html inside there you will about using the FragmentActivity instead of the Activity. Read this link http://developer.android.com/tools/extras/support-library.html as it will have the needed libraries to implement the Fragments in older versions of the SDK. It does looks like you looking for some navigation buttons that reside on the bottom of the layout. In order to fully implement a layout that has this view on the bottom of the screen in SDK 8, you will need to create your own View and place it on the bottom of the screen. RelativeLayout and alignParentBottom = "true" will accomplish this. There is also a way to do this using a ViewPager which will also work in the backwards compatibility requirements you have. I am sorry the amount of information I am throwing at you but I really would recommend looking into other questions posted by users on this topic. How to navigate to another page in android? for example. Good luck and everything you are looking for is able to be learned through a Google search. Maybe not all at once.

Formatting JEditorPane's cursor, tooltips, links

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.
How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried
EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.
What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.
I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?
An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!
As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3
Just provide an id to your tag like this
<h1><a id = "top"></a>First Line</h1>
Now somewhere in the bottom of your page write this :
<p>Return to TOP</p>
Clicking this link, you will reach the above area of the PAGE.
Points 1 & 2 may be addressed using the approach mentioned here. In particular, the view/model conversion methods will let you condition setCursor() and getToolTipText(), respectively.
You can get source from here http://java-sl.com/JEditorPaneStructureTool.html
It shows how to obtain text view bounds. First you get caret position for current mouse poiunter using viewToModel() method. Then go down the Views tree achieving leaf view and calcualte it's bounds. See this http://java-sl.com/tip_view_rectangle.html
If your mouse pointer in the view's rectangle then your mouse over text.
You can check whether the text in caret position is link and show your tooltip.
Use this http://java-sl.com/tip_links_in_editable.html to see how to detect whether mouse is over link.
Point 3.rd is answered by #nIcE cOw

Categories

Resources