开发者

How to pass array of value to another activity in android

I am getting the dynamic value from a web server like article desc, date,title etc. For one value article id, desc display in one webview. I am using array of webview. My requirement is that if the user clicks the first webview, I have to pass the first article id to another activity.

Can anybody tell me how to pass an array value to another activity?

Can anybody give an example?

This code explains I am getting the value from webservice and stored in arraylist and iterate the array list and display in webview and implement in touch event. My requirement is if user touch the first view. I have to pass first article id to another activity can anybody tell how to do this?

ArrayList articleParsedValue=new ArrayList();
articleParsedValue=articleParser.parseXmlArtic开发者_运维问答le(webservicevalue);

for(int i=0;i<articleParsedValue.size();i++)
        {
                ArticleDataSet articleDataset=(ArticleDataSet)articleParsedValue.get(i);
                HashMap<String, String> mapValue=new HashMap<String, String>();  

            WebView webviewcontent=new WebView(this);
           String html ="<html><body><div><label style=\"font:bold 17.5px verdana; color:#C1002B\">"+articleDataset.getArticle_title()+"<label style=\"font:13px verdana; color:#000000\">"+"|"+"</label>"+"<label style=\"font:bold 13px verdana; color:#000000\">"+articleDataset.getArticle_type()+"</label><br><label style=\"font:13px verdana; color:#AAAAAA\">"+articleDataset.getArticle_date()+" </label> </div>";
           html=html+"<div><label style=\"font:13px verdana; color:#000000\">"+articleDataset.getArticle_summary()+"</label></div></body></html>" ;
           webviewcontent.getSettings().setJavaScriptEnabled(true);
           webviewcontent.clearCache(true);
           webviewcontent.loadData(html, "text/html", "utf-8");
          webviewcontent.setOnTouchListener(this);
             mainlinear2.addView(webviewcontent);


        }


@Override
public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub

    {



            Intent newIntent=new Intent(this,MyCompaniesActivity.class);
            //newIntent.putExtra("articleid", ); 
            startActivity(newIntent);
            return false;
        }


You can use one of the Intent.putExtra methods. Then from the other activity use Intent.getExtra.


You should use intents : http://developer.android.com/guide/topics/intents/intents-filters.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜