Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

In this page you can find the example usage for android.os Bundle putInt.

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public static void sendHandlerMessage(Handler handler, int message_type, String[] message_var,
        String[] message_value) {
    Message msg1 = handler.obtainMessage();
    Bundle b = new Bundle();
    b.putInt("message_type", message_type);
    for (int i = 0; i < message_var.length; i++) {
        b.putString(message_var[i], message_value[i]);
    }/*from w  w w .  j a  v a  2 s.  c o m*/
    msg1.setData(b);
    handler.sendMessage(msg1);
}

From source file:eu.andlabs.studiolounge.gcp.GCPService.java

private void connect() {
    if (connecting)
        return;//from   w w  w  .ja  v  a  2 s .  c o m
    log("connecting");
    try {
        connecting = true;
        mSocketIO = new SocketIO("http://may.base45.de:7777", new IOCallback() {
            //            mSocketIO = new SocketIO("http://192.168.2.109:7777", new IOCallback() {

            @Override
            public void onConnect() { // auto login
                log("connected to GCP game server!");
                if (mApp != null) {
                    mSocketIO.emit("login", "I am " + mName);
                    mSocketIO.emit("state");
                }
                connecting = false;
            }

            @Override
            public void onMessage(String text, IOAcknowledge ack) {
                Bundle b = new Bundle();
                String[] msplit = text.split(":");
                b.putString("player", msplit[0]);
                b.putString("msg", msplit[1]);
                Log.d("CHAT", msplit[0]);
                dispatchMessage(CHAT, b);
            }

            @Override
            public void on(String type, IOAcknowledge ack, Object... data) {
                log("incoming message:" + type + " --- " + data);
                try {
                    if (type.equals("login")) {
                        loggedIn = true;
                        dispatchMessage(LOGIN, data[0].toString());
                    } else if (type.equals("welcome")) {
                        // dispatchMessage(LOGIN,
                        // data[0].toString().split("in as ")[1]);
                    } else if (type.equals("host")) {
                        JSONObject json = (JSONObject) data[0];
                        Bundle b = new Bundle();
                        b.putString("game", json.getString("game"));
                        b.putString("host", json.getString("host"));
                        dispatchMessage(HOST, b);
                    } else if (type.equals("join")) {
                        JSONObject json = (JSONObject) data[0];
                        Bundle b = new Bundle();
                        b.putString("game", json.getString("game"));
                        b.putString("guest", json.getString("guest"));
                        dispatchMessage(JOIN, b);
                    } else if (type.equals("state")) {
                        JSONObject json = (JSONObject) data[0];
                        JSONArray players = json.getJSONArray("players");
                        for (int i = 0; i < players.length(); i++) {
                            JSONObject player = players.getJSONObject(i);
                            dispatchMessage(LOGIN, player.getString("name"));
                            if (player.has("game")) {
                                Bundle b = new Bundle();
                                JSONObject game = player.getJSONObject("game");
                                b.putString("game", game.getString("id"));
                                b.putString("host", player.getString("name"));
                                b.putInt("joined", game.getInt("joined"));
                                b.putInt("min", game.getInt("min"));
                                b.putInt("max", game.getInt("max"));
                                dispatchMessage(HOST, b);
                            }
                        }
                        JSONArray chat = json.getJSONArray("chat");
                        for (int i = 0; i < chat.length(); i++) {
                            JSONObject msg = chat.getJSONObject(i);
                            Bundle b = new Bundle();
                            b.putString("player", msg.getString("player"));
                            b.putString("msg", msg.getString("msg"));
                            dispatchMessage(CHAT, b);
                        }
                    } else if (type.equals("move")) {
                        JSONObject json = (JSONObject) data[0];
                        Bundle b = new Bundle();
                        for (Iterator<String> i = json.keys(); i.hasNext();) {
                            String key = i.next();
                            b.putString(key, json.getString(key));
                            Log.i("json", "converting -  key:" + key + "  /  Value: " + json.getString(key));
                        }
                        dispatchMessage(CUSTOM, b);
                    } else if (type.equals("unhost")) {
                        Bundle b = new Bundle();
                        JSONObject json = (JSONObject) data[0];
                        b.putString("host", json.getString("host"));
                        b.putString("game", json.getString("game"));
                        dispatchMessage(UNHOST, b);
                    } else {
                        dispatchMessage(CHAT, "BAD protocol message: " + type);
                        Log.d("GCP", "" + data[0].getClass().getName());
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onMessage(JSONObject json, IOAcknowledge ack) {
            }

            @Override
            public void onDisconnect() {
                log("lost game server.");
                connecting = false;
                loggedIn = false;
            }

            @Override
            public void onError(SocketIOException error) {
                error.printStackTrace();
                connecting = false;
                loggedIn = false;
                log(error);
            }
        });
    } catch (Exception e) {
        log(e);
        loggedIn = false;
        connecting = false;
        dispatchMessage(CHAT, "GCP Service Error:   " + e.toString());
        e.printStackTrace();
    }
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name : createVideoLayout//from   ww  w.j a  va 2 s  .c o m
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */

public void createVideoLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutVideo);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    int intial = 0;
    if (videoresGooruOid.size() > 4) {
        intial = videoresGooruOid.size() - 5;
    } else {
        videoRight.setVisibility(View.GONE);
    }

    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.video_ico));
        intial++;
        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + videoresGooruOid.size());
                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Video";
                resourceGooruId = videoresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", videoresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createslideLayout/*from   ww w. ja v a2s  .c o m*/
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// slide
public void createslideLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutSlide);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (slideresGooruOid.size() > 4) {
        intial = slideresGooruOid.size() - 5;
    } else {
        slideRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.slides_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + slideresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Slide";
                resourceGooruId = slideresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", slideresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);
            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createwebsiteLayout//  w ww  .  j  ava  2 s .com
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// website
public void createwebsiteLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutWebsite);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (websiteresGooruOid.size() > 4) {
        intial = websiteresGooruOid.size() - 5;
    } else {
        websiteRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.website_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + websiteresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Website";
                resourceGooruId = websiteresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", websiteresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createhandoutLayout// ww w.j  av a  2 s.com
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// handout
public void createhandoutLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutHandout);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (handoutresGooruOid.size() > 4) {
        intial = handoutresGooruOid.size() - 5;
    } else {
        handoutRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.handouts_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + handoutresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Handout";
                resourceGooruId = handoutresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", handoutresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name : createlessonLayout/*  w  w w .ja  v a2  s  . c  om*/
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// lesson
public void createlessonLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutLesson);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (lessonresGooruOid.size() > 4) {
        intial = lessonresGooruOid.size() - 5;
    } else {
        lessonRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.lesson_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + lessonresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Lesson";
                resourceGooruId = lessonresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", lessonresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createinteractiveLayout
 * //from  w w w  .j  ava  2s  .c  o  m
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// interactive
public void createinteractiveLayout(List<String> resincUrls, List<String> resincTitle,
        List<String> resincCategory, List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutInteractive);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (interactiveresGooruOid.size() > 4) {
        intial = interactiveresGooruOid.size() - 5;
    } else {
        interactiveRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.interactive_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + interactiveresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Interactive";
                resourceGooruId = interactiveresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", interactiveresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createtextbookLayout// www.j  a v a 2s. c  o m
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// textbook
public void createtextbookLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutTextbook);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;

    int intial = 0;
    if (textbookresGooruOid.size() > 4) {
        intial = textbookresGooruOid.size() - 5;
    } else {
        textbookRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.textbook_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + textbookresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Textbook";
                resourceGooruId = textbookresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", textbookresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createexamLayout/*from  w w  w  .j a  va  2 s  .co m*/
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */

// exam
public void createexamLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutExam);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (examresGooruOid.size() > 4) {
        intial = examresGooruOid.size() - 5;
    } else {
        examRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.exam_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + examresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Exam";
                resourceGooruId = examresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", examresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}