"; private CharSequence mCharSequence1 = "中华人民共和国国歌是《义勇军进行曲》。"; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_label_layout); mContext = this; mLabelLayout = (LabelLayout) findViewById(R.id.label_layout); mLabelLayout.setOnLabelClickListener(this); findViewById(R.id.btn_add_label).setOnClickListener(this); findViewById(R.id.btn_delete_label).setOnClickListener(this); findViewById(R.id.btn_update_label).setOnClickListener(this); findViewById(R.id.btn_change_text).setOnClickListener(this); findViewById(R.id.btn_get_result).setOnClickListener(this); findViewById(R.id.btn_clear).setOnClickListener(this); findViewById(R.id.btn_extra_content).setOnClickListener(this); mEditText = (EditText) findViewById(R.id.edit_text); mEditText.setText(mCharSequence); //下面是LabelView参数设置 mLabelView = new LabelView(this); mLabelView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mLabelView.setLabelPadding(5, 5, 5, 5); mLabelView.setLabelTextSize(16); mLabelView.setLabelGravity(LabelView.TextGravityEnum.CENTER); mLabelView.setLabelTextColor(ContextCompat.getColor(this, R.color.colorPrimary)); mLabelView.setLabelStrokeColor(ContextCompat.getColor(this, R.color.colorPrimary)); mLabelView.setLabelStrokeWidth(4); mLabelView.setLabelCornerRadious(15); mLabelView.setLabelBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent)); mLabelView.setLabelMaxLines(3); mLabelView.setIsShowMore(true); mLabelView.setLabelMoreText("--更多--"); mLabelView.setLabelOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(mContext, "You clicked " ((LabelView) v).getLabelText(), Toast.LENGTH_SHORT).show(); } }); mLabelLayout.setLabelView(mLabelView); } @Override public void onLabelClick(TextView label) { Toast.makeText(mContext, "You clicked " label.getText().toString().trim(), Toast.LENGTH_SHORT).show(); } /** * 添加label */ private void addNewLabel() { mLabelLayout.addLabels(mEditText.getText()); } /** * 删除label */ private void deleteLabel() { mLabelLayout.deleteLabel(0); } /** * 修改label */ private void updateLabel() { int count = mLabelLayout.getLabelsCount(); for (int i = 0; i < count; i ) { mLabelLayout.updateLabel(i, "哈哈哈哈!"); } } /** * 改变文本 */ private void changeCharSequence() { if ("0".equals(mTag)) { mEditText.setText(mCharSequence1); mTag = "1"; } else { mEditText.setText(mCharSequence); mTag = "0"; } } /** * 获取结果 */ private void getResult() { StringBuilder stringBuilder = new StringBuilder(); int count = mLabelLayout.getLabelsCount(); for (int i = 0; i < count; i ) { LabelView labelView = (LabelView) mLabelLayout.getChildAt(i); stringBuilder.append(String.format("第%s个Label的文本是:%s ", i 1, labelView.getLabelText())); } Toast.makeText(mContext, stringBuilder.toString(), Toast.LENGTH_SHORT).show(); } private void clearInput() { mLabelLayout.removeAllViews(); } private void extraContent() { //这个时候我们就可以自己去修改LabelView的参数了 mLabelView.setLabelCornerRadious(50); mLabelView.setLabelPadding(10, 5, 10, 5); mLabelView.setLabelForceMeasure(false); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_add_label: addNewLabel(); break; case R.id.btn_delete_label: deleteLabel(); break; case R.id.btn_update_label: updateLabel(); break; case R.id.btn_change_text: changeCharSequence(); break; case R.id.btn
《续座头市物语》由胜新太郎 水谷八重子 万里昌代 若山富三郎 泽村宗之助 杉山昌三 等主演,森一生 导演的动作,冒险电影...
免責聲明:若本站收錄的資源侵犯了您的權益,我們會及時刪除侵權內容,謝謝合作!