user1108339
user1108339

Reputation: 121

Slide Screens in Activity android sdk

I have Activity where i have information. How can i do so that when i slide to the side i could see another information? Is this possible to do it in one Activity? What the java code should be? What should i change in .xml files ?

java:

package com.lineage.goddess;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class LineageHelpActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.help);
        openRawResource();
        InputStream iFile = getResources().openRawResource(R.raw.lineagehelp);
        TextView helpText =(TextView) findViewById(R.id.TextView_HelpText);
        String strFile = inputStreamToString(iFile);
        helpText.setText(strFile);
    }

    private String inputStreamToString(InputStream iFile) 
    {               
        Writer writer = new StringWriter();
        if(iFile!=null)
        {
            char[] buffer = new char[1024];
            try{
                Reader reader = new BufferedReader(
                        new InputStreamReader(iFile, "UTF-8"));
                int n;
                while ((n = reader.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }
            } catch (UnsupportedEncodingException e) {
                return e.toString();
            } catch (IOException e) {
                return e.toString();
            }finally
            {
                try {
                    iFile.close();
                } catch (IOException e) {
                    return e.toString();
                }
            }
        }
       String result = writer.toString();
       return result;
    }



    private void openRawResource() {
        // TODO Auto-generated method stub

    }
}

Upvotes: 0

Views: 1348

Answers (1)

Iiro Krankka
Iiro Krankka

Reputation: 5239

Do you mean like Google+ and Market do it? You may want to look up the ViewPager:

http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html

Upvotes: 1

Related Questions