Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help Activity in Android App

Tags:

android

I want to put some Help Text in an Activity when a MenuItem Help in my Android App is clicked. Currently I have the MenuItem Help working so that when it is click it opens up a new Activity.

What would be the best way to put formatted text in that Help Activity's contentview layout? I think I will need the ability to Scroll in this view. Should I use a TextView? What is the recommended way of doing this?

Thanks in advance.

like image 876
Aakash Avatar asked Dec 09 '22 12:12

Aakash


2 Answers

I've used a WebView to display Help and stored the help html locally. This worked out well, however it really depends on what you want your help to look like.

My xml looks like this:

<WebView android:id="@+id/yourwebview"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         />

Then in your activity load and show the page like this. about.html is in the assets folder, same level as your res folder.

    WebView browser = (WebView)findViewById(R.id.yourwebview);

    WebSettings settings = browser.getSettings();
    settings.setJavaScriptEnabled(true);

    browser.loadUrl("file:///android_asset/about.html");
like image 60
Ryan Reeves Avatar answered Dec 22 '22 00:12

Ryan Reeves


Falmarri's answer may be a matter of opinion.. using an ImageView would be a strange ( and possibly frustrating ) approach.

I would suggest reading up on how to make an AlertDialog. You could then just enter your text using the AlertDialog.setMessage() method, or one of the more complicated approaches and fill in the AlertDialog with a custom view. The Android docs have a good step-by-step introduction to making AlertDialogs.

like image 21
Snailer Avatar answered Dec 22 '22 00:12

Snailer