Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

In this page you can find the example usage for android.widget TextView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java

private void tryRenderTags() {
    if (mTagMetadata == null || mTagsString == null) {
        return;//from ww  w. ja  va2s.c  o  m
    }

    if (TextUtils.isEmpty(mTagsString)) {
        mTagsContainer.setVisibility(View.GONE);
    } else {
        mTagsContainer.setVisibility(View.VISIBLE);
        mTags.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(this);
        String[] tagIds = mTagsString.split(",");

        List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>();
        for (String tagId : tagIds) {
            if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                continue;
            }

            TagMetadata.Tag tag = mTagMetadata.getTag(tagId);
            if (tag == null) {
                continue;
            }

            tags.add(tag);
        }

        if (tags.size() == 0) {
            mTagsContainer.setVisibility(View.GONE);
            return;
        }

        Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR);

        for (final TagMetadata.Tag tag : tags) {
            TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false);
            chipView.setText(tag.getName());

            if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) {
                ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape());
                colorDrawable.setIntrinsicWidth(mTagColorDotSize);
                colorDrawable.setIntrinsicHeight(mTagColorDotSize);
                colorDrawable.getPaint().setStyle(Paint.Style.FILL);
                chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null);
                colorDrawable.getPaint().setColor(tag.getColor());
            }

            chipView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish(); // TODO: better encapsulation
                    Intent intent = new Intent(EventDetailActivity.this, BrowseSessionsActivity.class)
                            .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId())
                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            });

            mTags.addView(chipView);
        }
    }
}

From source file:com.SpeechEd.SpeechEdEditActivity.java

/**
 * Called from both onCreate and onConfigurationChanged
 * (if the user switched layouts)// w ww  .  jav a 2s . c om
 */
private void loadGui() {
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.editor);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mDensity = metrics.density;

    mMarkerLeftInset = (int) (46 * mDensity);
    mMarkerRightInset = (int) (48 * mDensity);
    mMarkerTopOffset = (int) (10 * mDensity);
    mMarkerBottomOffset = (int) (10 * mDensity);

    mStartText = (TextView) findViewById(R.id.starttext);
    mStartText.addTextChangedListener(mTextWatcher);
    mEndText = (TextView) findViewById(R.id.endtext);
    mEndText.addTextChangedListener(mTextWatcher);

    mPlayButton = (ImageButton) findViewById(R.id.play);
    mPlayButton.setOnClickListener(mPlayListener);
    mRewindButton = (ImageButton) findViewById(R.id.rew);
    mRewindButton.setOnClickListener(mRewindListener);
    mFfwdButton = (ImageButton) findViewById(R.id.ffwd);
    mFfwdButton.setOnClickListener(mFfwdListener);
    mZoomInButton = (ImageButton) findViewById(R.id.zoom_in);
    mZoomInButton.setOnClickListener(mZoomInListener);
    mZoomOutButton = (ImageButton) findViewById(R.id.zoom_out);
    mZoomOutButton.setOnClickListener(mZoomOutListener);
    mSaveButton = (ImageButton) findViewById(R.id.save);
    mSaveButton.setOnClickListener(mSaveListener);

    TextView markStartButton = (TextView) findViewById(R.id.mark_start);
    markStartButton.setOnClickListener(mMarkStartListener);
    TextView markEndButton = (TextView) findViewById(R.id.mark_end);
    markEndButton.setOnClickListener(mMarkStartListener);

    enableDisableButtons();

    mWaveformView = (WaveformView) findViewById(R.id.waveform);
    mWaveformView.setListener(this);

    mInfo = (TextView) findViewById(R.id.info);
    mInfo.setText(mCaption);

    mMaxPos = 0;
    mLastDisplayedStartPos = -1;
    mLastDisplayedEndPos = -1;

    if (mSoundFile != null) {
        mWaveformView.setSoundFile(mSoundFile);
        mWaveformView.recomputeHeights(mDensity);
        mMaxPos = mWaveformView.maxPos();
    }

    mStartMarker = (MarkerView) findViewById(R.id.startmarker);
    mStartMarker.setListener(this);
    mStartMarker.setAlpha(255);
    mStartMarker.setFocusable(true);
    mStartMarker.setFocusableInTouchMode(true);
    mStartVisible = true;

    mEndMarker = (MarkerView) findViewById(R.id.endmarker);
    mEndMarker.setListener(this);
    mEndMarker.setAlpha(255);
    mEndMarker.setFocusable(true);
    mEndMarker.setFocusableInTouchMode(true);
    mEndVisible = true;

    updateDisplay();
}

From source file:com.shengtao.chat.chatUI.adapter.MessageAdapter.java

/**
 * ???/*from  www  .  j  a  va 2  s  . co m*/
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    TextView locationView = ((TextView) convertView.findViewById(id.tv_location));
    LocationMessageBody locBody = (LocationMessageBody) message.getBody();
    locationView.setText(locBody.getAddress());
    LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
    locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
    locationView.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", Type.LOCATION.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return false;
        }
    });

    if (message.direct == Direct.RECEIVE) {
        return;
    }
    // deal with send message
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:hu.fnf.devel.atlas.Atlas.java

private void addChilds(View parent, LinearLayout pll) {
    Uri.Builder builder = new Builder();
    builder.scheme("content");
    builder.authority(AtlasData.DB_AUTHORITY);
    builder.appendPath(AtlasData.TABLE_CATEGORIES);
    builder.appendPath("childs");
    builder.appendPath(String.valueOf(parent.getId()));

    Cursor items = getContentResolver().query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null);

    if (items != null && items.moveToFirst()) {
        LinearLayout ll = null;/*from  w  ww  . ja  va2  s.c om*/
        do {
            ll = new LinearLayout(getApplicationContext());
            LayoutParams llp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            ll.setLayoutParams(llp);
            TextView child = new TextView(getApplicationContext());
            child.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse);

            ll.setId(items.getInt(AtlasData.CATEGORIES_ID));
            child.setId(items.getInt(AtlasData.CATEGORIES_ID));
            child.setText(items.getString(AtlasData.CATEGORIES_NAME));
            for (int i = 0; i < AtlasData.MAX_CAT_DEPTH - items.getInt(AtlasData.CATEGORIES_DEPTH); i++) {
                TextView holder = new TextView(getApplicationContext());
                holder.setText("        ");
                ll.addView(holder);
            }

            child.setClickable(true);

            Log.d("Atlas", "build to ll: " + child.getText().toString());
            ll.addView(child);

            ll.setOnClickListener(onCatClick);
            child.setOnClickListener(onCatClick);

            View line = new View(getApplicationContext());

            line.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1));
            line.setBackgroundColor(Color.GRAY);

            pll.addView(line);
            pll.addView(ll);
            Log.d("Atlas", "build to pll: " + ll.getId());

            addChilds(child, pll);
        } while (items.moveToNext());
        items.close();
    } else {
        // no more kids
        return;
    }
}

From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java

private void tryRenderTags() {
    if (mTagMetadata == null || mTagsString == null) {
        return;//from   ww w. j av  a  2s  .  c o  m
    }

    if (TextUtils.isEmpty(mTagsString)) {
        mTagsContainer.setVisibility(View.GONE);
    } else {
        mTagsContainer.setVisibility(View.VISIBLE);
        mTags.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(this);
        String[] tagIds = mTagsString.split(",");

        List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>();
        for (String tagId : tagIds) {
            if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                continue;
            }

            TagMetadata.Tag tag = mTagMetadata.getTag(tagId);
            if (tag == null) {
                continue;
            }

            tags.add(tag);
        }

        if (tags.size() == 0) {
            mTagsContainer.setVisibility(View.GONE);
            return;
        }

        Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR);

        for (final TagMetadata.Tag tag : tags) {
            TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false);
            chipView.setText(tag.getName());

            if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) {
                ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape());
                colorDrawable.setIntrinsicWidth(mTagColorDotSize);
                colorDrawable.setIntrinsicHeight(mTagColorDotSize);
                colorDrawable.getPaint().setStyle(Paint.Style.FILL);
                chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null);
                colorDrawable.getPaint().setColor(tag.getColor());
            }

            chipView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish(); // TODO: better encapsulation
                    Intent intent = new Intent(CurrentSessionActivity.this, BrowseSessionsActivity.class)
                            .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId())
                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            });

            mTags.addView(chipView);
        }
    }
}

From source file:dong.lan.tuyi.activity.MainActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.toolbar_community:
        startActivity(new Intent(MainActivity.this, TuyiHomeActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;//from   w  w  w  .j  a  v a  2 s . c om
    case R.id.toolbar_tuyi:
        startActivity(new Intent(MainActivity.this, TuMapActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.my_Favorite:
        startActivity(new Intent(MainActivity.this, FavoriteActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_des:
        isGetWeather = true;
        break;
    case R.id.offline_tuyi:
        startActivityForResult(new Intent(MainActivity.this, OfflineTuyiActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_community:
        Lock.canPop = false;
        startActivityForResult(new Intent(MainActivity.this, TuyiCommunityActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_head:
        if (Config.tUser == null) {
            Show("????");
            return;
        }
        Lock.canPop = false;
        final Dialog dialog = new AlertDialog.Builder(MainActivity.this).create();
        dialog.setCancelable(true);
        dialog.show();
        dialog.getWindow().setContentView(R.layout.dialog_set_head_img);
        TextView msg = (TextView) dialog.findViewById(R.id.dialog_msg);
        msg.setText("?");
        TextView dialog_left = (TextView) dialog.findViewById(R.id.dialog_left);
        TextView dialog_right = (TextView) dialog.findViewById(R.id.dialog_right);
        dialog_left.setText("");
        dialog_right.setText("");
        dialog_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                File dir = new File(Constant.PICTURE_PATH);
                if (!dir.exists()) {
                    dir.mkdirs();
                }
                // 
                File file = new File(dir,
                        username + "_head_" + new SimpleDateFormat(TimeUtil.FORMAT_NORMAL).format(new Date()));
                filePath = file.getAbsolutePath();// ??
                Uri imageUri = Uri.fromFile(file);

                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_CAMERA);
            }
        });
        dialog_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                Intent intent = new Intent(Intent.ACTION_PICK, null);
                intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
                startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_LOCATION);
            }
        });

        break;
    case R.id.user_center:
        if (Config.tUser != null) {
            Lock.canPop = false;
            startActivityForResult(
                    new Intent(MainActivity.this, UserCenter.class).putExtra("USER", Config.tUser), 100);
            overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        }
        break;
    case R.id.user_albums:
        startActivityForResult(new Intent(MainActivity.this, TuyiPlayActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_setting:
        startActivityForResult(new Intent(MainActivity.this, MyRadarActivity.class), 100);
        break;
    case R.id.my_interested:
        startActivityForResult(new Intent(MainActivity.this, MyInterestedActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;

    }
}

From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java

private void tryRenderTags() {
    if (mTagMetadata == null || mTagsString == null || !isAdded()) {
        return;/*from  w  w w  .j  a va 2 s.c  o  m*/
    }

    if (TextUtils.isEmpty(mTagsString)) {
        mTagsContainer.setVisibility(View.GONE);
    } else {
        mTagsContainer.setVisibility(View.VISIBLE);
        mTags.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(getActivity());
        String[] tagIds = mTagsString.split(",");

        List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>();
        for (String tagId : tagIds) {
            if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                continue;
            }

            TagMetadata.Tag tag = mTagMetadata.getTag(tagId);
            if (tag == null) {
                continue;
            }

            tags.add(tag);
        }

        if (tags.size() == 0) {
            mTagsContainer.setVisibility(View.GONE);
            return;
        }

        Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR);

        for (final TagMetadata.Tag tag : tags) {
            TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false);
            chipView.setText(tag.getName());

            if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) {
                ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape());
                colorDrawable.setIntrinsicWidth(mTagColorDotSize);
                colorDrawable.setIntrinsicHeight(mTagColorDotSize);
                colorDrawable.getPaint().setStyle(Paint.Style.FILL);
                chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null);
                colorDrawable.getPaint().setColor(tag.getColor());
            }

            chipView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    getActivity().finish(); // TODO: better encapsulation
                    Intent intent = new Intent(getActivity(), BrowseSessionsActivity.class)
                            .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId())
                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            });

            mTags.addView(chipView);
        }
    }
}

From source file:com.com.easemob.chatuidemo.adapter.MessageAdapter.java

/**
 * ???//www. java  2s  .co m
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location));
    LocationMessageBody locBody = (LocationMessageBody) message.getBody();
    locationView.setText(locBody.getAddress());
    LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
    locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
    locationView.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()),
                    ChatMessage.REQUEST_CODE_CONTEXT_MENU);
            return false;
        }
    });

    if (message.direct == EMMessage.Direct.RECEIVE) {
        return;
    }
    // deal with send message
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:dong.lan.tuyi.activity.MainActivity.java

/**
 * ?//from  ww  w.  j a  v  a  2 s . c  o  m
 */
private void initView() {
    loc_des = (TextView) findViewById(R.id.user_des);
    loc_des.setOnClickListener(this);
    tip = (TextView) findViewById(R.id.tip);
    tipLayout = (LinearLayout) findViewById(R.id.tip_layout);
    if (Config.tUser == null) {
        tipLayout.setVisibility(View.VISIBLE);
    }

    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("");
    toolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);
    toolbar.inflateMenu(R.menu.toolbar_menu);
    toolbar.setOnMenuItemClickListener(itemClickListener);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }
    };
    drawerToggle.syncState();
    drawerLayout.setDrawerListener(drawerToggle);

    unreadLabel = (TextView) findViewById(R.id.unread_msg_number);
    unreadAddressLable = (TextView) findViewById(R.id.unread_address_number);
    net_tip = (TextView) findViewById(R.id.net_tip);
    net_tip.setOnClickListener(net_error);
    mTabs = new Button[4];
    mTabs[0] = (Button) findViewById(R.id.btn_conversation);
    mTabs[1] = (Button) findViewById(R.id.btn_address_list);
    mTabs[2] = (Button) findViewById(R.id.btn_setting);
    mTabs[3] = (Button) findViewById(R.id.btn_user_main);
    // tab?
    mTabs[3].setSelected(true);
    currentTabIndex = 3;
    TextView user_center = (TextView) findViewById(R.id.user_center);
    findViewById(R.id.my_interested).setOnClickListener(this);
    findViewById(R.id.user_albums).setOnClickListener(this);
    TextView user_setting = (TextView) findViewById(R.id.user_setting);
    findViewById(R.id.my_Favorite).setOnClickListener(this);
    head = (ImageView) findViewById(R.id.user_head);
    TextView offlineTuyi = (TextView) findViewById(R.id.offline_tuyi);
    findViewById(R.id.toolbar_community).setOnClickListener(this);
    findViewById(R.id.toolbar_tuyi).setOnClickListener(this);
    findViewById(R.id.user_community).setOnClickListener(this);
    offlineTuyi.setOnClickListener(this);
    head.setOnClickListener(this);
    loc_des.setOnClickListener(this);
    user_setting.setOnClickListener(this);
    user_center.setOnClickListener(this);
    registerForContextMenu(mTabs[1]);
    if (Config.isSetLock(this)) {
        loc_des.post(new Runnable() {
            @Override
            public void run() {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Lock.canPop = true;
                        Lock.locking(MainActivity.this, findViewById(R.id.slide_Main), Lock.UNLOCK);
                    }
                });
            }
        });
    }
    head.post(new Runnable() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (!Config.getGuide1(getBaseContext())) {
                        guidePop();
                    }
                }
            });
        }
    });
}

From source file:cn.hbm.superwechat.adapter.MessageAdapter.java

@SuppressWarnings("ResourceType")
private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) {
    try {//from  w w w . jav a 2  s .c  o  m
        parentView.removeAllViews();
        for (int i = 0; i < jsonArr.length(); i++) {
            final String itemStr = jsonArr.getString(i);
            final TextView textView = new TextView(context);
            textView.setText(itemStr);
            textView.setTextSize(15);
            try {
                XmlPullParser xrp = context.getResources().getXml(R.drawable.menu_msg_text_color);
                textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp));
            } catch (Exception e) {
                e.printStackTrace();
            }
            textView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ((ChatActivity) context).sendText(itemStr);
                }
            });
            LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            llLp.bottomMargin = DensityUtil.dip2px(context, 3);
            llLp.topMargin = DensityUtil.dip2px(context, 3);
            parentView.addView(textView, llLp);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}