CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   printing images and text within a tabhost (http://www.codingforums.com/showthread.php?t=265625)

jordandap 06-19-2012 02:27 PM

printing images and text within a tabhost
 
Hello I have the following code already i have the explanation on what i want to do within the code


Code:

public class Main extends Activity implements OnClickListener {

    TabHost th;
    TextView showResults;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        th = (TabHost) findViewById(R.id.tabhost);
        Button newTab = (Button) findViewById(R.id.bVanilla);

        newTab.setOnClickListener(this);

        th.setup();
        TabSpec specs = th.newTabSpec("Main");
        specs.setContent(R.id.tab1);
        specs.setIndicator("Main");
        th.addTab(specs);
    }

    public void onClick(View arg0) {
        switch (arg0.getId()) {
        case R.id.bVanilla:

            TabSpec ourSpec = th.newTabSpec("tabVanilla");
            ourSpec.setContent(new TabHost.TabContentFactory() {

                public View createTabContent(String tag) {

                    TextView text = new TextView(Main.this);
                    text.setText("text line one\n");
                    /* after this print oh line 1 i want to
                        display a image for example test.png
                        then break a line then another line of
                        text then break again then another image
                        was wondering if it would be easier to do this with an 2 
                        arrays one for text and one for images
                        but not sure how I would achieve this
                        greatly appreciate the help
                  */
                    return (text);
                }
            });
            ourSpec.setIndicator("New");
            th.addTab(ourSpec);

            break;
        }
    }
}



All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.