Java源码示例:android.widget.TextView

示例1
public void initViews(View rootView) {
    this.imgReturn = rootView.findViewById(R.id.img_ai_follow_return);
    this.btnOk = rootView.findViewById(R.id.btn_ai_follow_confirm_ok);
    this.cbTip = (CheckBox) rootView.findViewById(R.id.cb_ai_follow_confirm_ok);
    this.vItemSelect = rootView.findViewById(R.id.ll_ai_follow_item);
    this.vConfirm = rootView.findViewById(R.id.rl_ai_follow_info_confirm);
    this.tvTitle = (TextView) rootView.findViewById(R.id.tv_ai_follow_title);
    this.tvContentTip1 = (TextView) rootView.findViewById(R.id.tv_ai_follow_confirm_title1);
    this.tvContentTip2 = (TextView) rootView.findViewById(R.id.tv_ai_follow_confirm_title2);
    this.svTips = (ScrollView) rootView.findViewById(R.id.sv_ai_items);
    this.vItem1 = rootView.findViewById(R.id.rl_ai_follow_normal);
    this.vItem2 = rootView.findViewById(R.id.rl_ai_follow_parallel);
    this.vItem3 = rootView.findViewById(R.id.rl_ai_follow_lockup);
    this.vItemSelect.setVisibility(0);
    this.vConfirm.setVisibility(8);
    this.tvTitle.setText(this.contentView.getContext().getString(R.string.x8_ai_fly_follow));
    this.imgFlag = (ImageView) rootView.findViewById(R.id.img_follow_flag);
}
 
示例2
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // Inflate list items.
    if (null == convertView) {
        convertView = layoutInflater.inflate(R.layout.list_item, null);
    }

    convertView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((TextView) findViewById(R.id.selection_row_value)).setText(
                    String.valueOf(position));
        }
    });

    return super.getView(position, convertView, parent);
}
 
示例3
@Override
public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header, int sectionIndex) {
	TextView folderName = (TextView) holder.getView().findViewById(R.id.select_artist_folder_2);

	String musicFolderId = Util.getSelectedMusicFolderId(context);
	if(musicFolderId != null) {
		for (MusicFolder musicFolder : musicFolders) {
			if (musicFolder.getId().equals(musicFolderId)) {
				folderName.setText(musicFolder.getName());
				break;
			}
		}
	} else {
		folderName.setText(R.string.select_artist_all_folders);
	}
}
 
示例4
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    VideoItem data = getItem(position);

    if (null == convertView) {
        convertView = layoutInflater.inflate(R.layout.row_video_list, null);
    }

    ImageView imageView = convertView.findViewById(R.id.image);
    TextView textView = convertView.findViewById(R.id.txt_image_name);

    Glide.with(getContext().getApplicationContext())
            .load(data.getPath())
            .into(imageView);

    textView.setText(data.getPath());

    return convertView;
}
 
示例5
public DefaultLoadView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    tvContent = new TextView(context);
    tvContent.setId(View.generateViewId());
    addView(tvContent);
    RelativeLayout.LayoutParams contentParams = (LayoutParams) tvContent.getLayoutParams();
    contentParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    progressBar = new ProgressBar(context);
    addView(progressBar);
    final float density = getContext().getResources().getDisplayMetrics().density;
    RelativeLayout.LayoutParams params = (LayoutParams) progressBar.getLayoutParams();
    params.width = (int) (20 * density);
    params.height = (int) (20 * density);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    params.rightMargin = (int) (10 * density);
    params.addRule(RelativeLayout.LEFT_OF, tvContent.getId());
    progressBar.setLayoutParams(params);
}
 
示例6
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mResultView = (TextView) view.findViewById(R.id.resultView);
    view.findViewById(R.id.button).setOnClickListener(
            new OnClickListener() {
                @Override
                public void onClick(View v) {
                    startFragmentForResult(NumbersList.class, REQUEST_CODE);
                }
            });
    FragmentManager fragmentManager = getChildFragmentManager();
    if (fragmentManager.findFragmentByTag("TAG_CHILD") == null) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.add(R.id.childContainer, new Child(), "TAG_CHILD");
        ft.commitAllowingStateLoss();
        fragmentManager.executePendingTransactions();
    }
}
 
示例7
public void show(Context context, @StringRes int titleId, @StringRes int messageId,
                 DialogInterface.OnCancelListener listener) {
    dismiss();
    DialogBuilder builder = new DialogBuilder(context);
    if (titleId > 0) {
        builder.setTitle(titleId);
    }
    LayoutInflater inflater = LayoutInflater.from(context);
    View itemView = inflater.inflate(R.layout.row_progress, null);
    messageTextView = (TextView) itemView.findViewById(R.id.text_progress);
    if (messageId > 0) {
        messageTextView.setText(messageId);
    }
    builder.addItem(itemView);
    builder.setOnCancelListener(listener);
    dialog = builder.show();
}
 
示例8
private ViewHolder getViewHolder(final View workingView)
{
    final Object tag = workingView.getTag();
    ViewHolder viewHolder = null;


    if (null == tag || !(tag instanceof ViewHolder))
    {
        viewHolder = new ViewHolder();

        viewHolder.nameView = (TextView) workingView.findViewById(R.id.name);
        viewHolder.mbView = (TextView) workingView.findViewById(R.id.mb);
        viewHolder.imageView = (ImageView) workingView.findViewById(R.id.icon);
        viewHolder.killView = (Button) workingView.findViewById(R.id.kill);
        viewHolder.pidView = (TextView) workingView.findViewById(R.id.pid);

        workingView.setTag(viewHolder);

    }
    else
    {
        viewHolder = (ViewHolder) tag;
    }

    return viewHolder;
}
 
示例9
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  btnIncreaseCounter = (Button) findViewById(R.id.btnWearIncreaseCounter);
  btnIncreaseCounter.getBackground().setColorFilter(0xFF1194F7, PorterDuff.Mode.MULTIPLY);
  tvCounter = (TextView) findViewById(R.id.tvCounter);
  tvCounter.setText(Integer.toString(count));

  client = new GoogleApiClient.Builder(this).addApi(Wearable.API)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .build();

  btnIncreaseCounter.setOnClickListener(clickListener);
}
 
示例10
@Override
protected void initViews() {

    mIvAvater = (ImageView) findViewById(R.id.setting_my_avater_img);
    mEtNickname = (EditText) findViewById(R.id.setting_my_nickname);
    mRgGender = (RadioGroup) findViewById(R.id.setting_baseinfo_rg_gender);
    mHtvConstellation = (TextView) findViewById(R.id.setting_birthday_htv_constellation);
    mHtvAge = (TextView) findViewById(R.id.setting_birthday_htv_age);
    mDpBirthday = (DatePicker) findViewById(R.id.setting_birthday_dp_birthday);

    mRbBoy = (RadioButton) findViewById(R.id.setting_baseinfo_rb_male);
    mRbGirl = (RadioButton) findViewById(R.id.setting_baseinfo_rb_female);

    mBtnBack = (Button) findViewById(R.id.setting_btn_back);
    mBtnNext = (Button) findViewById(R.id.setting_btn_next);

}
 
示例11
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3)
{
	// Cancel discovery because it's costly and we're about to connect
	mBtAdapter.cancelDiscovery();

	// Get the device MAC address, which is the last 17 chars in the View
	String info = ((TextView) v).getText().toString();
	String address = info.substring(info.length() - 17);
	//String address = "00:0D:18:A0:4E:35"; //FORCE OBD MAC Address
	// Create the result Intent and include the MAC address
	Intent intent = new Intent();
	intent.putExtra(EXTRA_DEVICE_ADDRESS, address);

	// Set result and finish this Activity
	setResult(Activity.RESULT_OK, intent);
	log.log(Level.FINE, "Sending Result...");
	finish();
}
 
示例12
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityThinJamBinding.inflate(getLayoutInflater());
    binding.setVm(new ViewModel(this));
    setContentView(binding.getRoot());
    JoH.fixActionBar(this);

    scanMeister.setFilter(customFilter);
    scanMeister.allowWide().unlimitedMatches();
    scanMeister.addCallBack2(this, TAG);

    ((TextView) findViewById(R.id.tjLogText)).setMovementMethod(new ScrollingMovementMethod());

    // handle incoming extras - TODO do we need to wait for service connect?
    final Bundle bundle = getIntent().getExtras();
    processIncomingBundle(bundle);

    LocationHelper.requestLocationForBluetooth(this);
}
 
示例13
private void init() {
        iLanguage();
        sendMessage("talk", getIPAddress() + strJoinToChatroom);
        app = (ApplicationUtil) this.getApplication();
        tvShow = (TextView) findViewById(R.id.tv_show);
        tvShow.setText(strShow);
        btnBack = (Button) findViewById(R.id.btn_back);
        btnBack.setOnClickListener(this);
        btnSend = (Button) findViewById(R.id.btn_send);
        btnSend.setText(strSend);
        btnSend.setOnClickListener(this);
        etContent = (EditText) findViewById(R.id.et_content);
        lvTalk = (ListView) findViewById(R.id.lv_talk);
        lvTalk.setDividerHeight(0);
        adapter = new TalkAdapter(this, list);
        lvTalk.setAdapter(adapter);
        lvTalk.smoothScrollToPosition(adapter.getCount() - 1);
//        tHandler.post(tRunnable);
        mThreadClient = new Thread(tRunnable);
        mThreadClient.start();
    }
 
示例14
public void resetView() {
       setContentView(R.layout.activity_forum);
	
       ForumConfig instance = (ForumConfig)MainActivity.instance;

       super.resetView();

       if (instance.isExternal) {
       	findViewById(R.id.newPostButton).setVisibility(View.GONE);
       	findViewById(R.id.postsButton).setVisibility(View.GONE);
       }

   	TextView text = (TextView) findViewById(R.id.postsLabel);
       if (instance.posts != null && instance.posts.length() > 0) {
        text.setText(instance.posts + " posts");
       } else {
        text.setText("");        	
       }
}
 
示例15
public View getView(int position, View convertView, ViewGroup parent) {
    View view;

    if (convertView == null) {
        view = mInflater.inflate(R.layout.wallpaper_picker_third_party_item, parent, false);
    } else {
        view = convertView;
    }

    ResolveInfo info = mThirdPartyWallpaperPickers.get(position).mResolveInfo;
    TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label);
    label.setText(info.loadLabel(mPackageManager));
    Drawable icon = info.loadIcon(mPackageManager);
    icon.setBounds(new Rect(0, 0, mIconSize, mIconSize));
    label.setCompoundDrawables(null, icon, null, null);
    return view;
}
 
示例16
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), mThemeId);

    // Title
    if (mTitle != null) {
        builder.setTitle(mTitle);
    }

    // Message
    if (mHasHtml) {
        TextView msg = new TextView(getActivity());
        msg.setText(Html.fromHtml(mMessage));
        msg.setMovementMethod(LinkMovementMethod.getInstance());
        builder.setView(msg);
    } else if (mMessage != null) {
        builder.setMessage(mMessage);
    }

    // Button text
    String buttonText;
    if (mButtonText != null) {
        buttonText = mButtonText;
    } else {
        buttonText = getString(android.R.string.ok);
    }
    builder.setPositiveButton(buttonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mOnCloseListener != null) {
                mOnCloseListener.onClose();
            }
        }
    });
    return builder.create();
}
 
示例17
public HeaderViewHolder(View itemView) {
    super(itemView);
    linearLayout = (LinearLayout) itemView.findViewById(R.id.lxw_id_item_helps_include_avertor);
    userimg = (nico.styTool.CircleImageView) linearLayout.findViewById(R.id.lxw_id_item_helps_userimg);
    username = (TextView) linearLayout.findViewById(R.id.lxw_id_item_helps_username);
    personality = (TextView) linearLayout.findViewById(R.id.lxw_id_item_helps_user_personality);
    creatTime = (TextView) linearLayout.findViewById(R.id.lxw_id_item_helps_create_time);
    content = (TextView) itemView.findViewById(R.id.lxw_id_item_helps_content);
    frameLayout = (FrameLayout) itemView.findViewById(R.id.lxw_id_item_helps_include_img);
    gridView = (GridView) frameLayout.findViewById(R.id.lxw_id_item_helps_gridview);
    contentImg = (ImageView) frameLayout.findViewById(R.id.lxw_id_item_helps_content_img);
}
 
示例18
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
    if (convertView == null)
    {
        // inflate a new view and add a tag
        convertView = mLayoutInflater.inflate(R.layout.integer_choices_spinner_item, parent, false);
        SpinnerItemTag tag = new SpinnerItemTag();
        tag.image = (ImageView) convertView.findViewById(R.id.integer_choice_item_image);
        tag.text = (TextView) convertView.findViewById(R.id.integer_choice_item_text);
        convertView.setTag(tag);
    }

    populateView(position, convertView);

    return convertView;
}
 
示例19
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent){
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.message_list_item, parent, false);

    // Set up the topic tokens
    TextView topicTextView = (TextView) rowView.findViewById(R.id.message_topic_text);
    String[] topicTokens = messages.get(position).getTopic().split("/");
    if (messages.get(position).getMessageType() == MessageType.Published) {
        topicTextView.setText(topicTokens[1] + " :: " + topicTokens[3] + " :: Published");
    } else if (messages.get(position).getMessageType() == MessageType.Received) {
        topicTextView.setText(topicTokens[1] + " :: " + topicTokens[3] + " :: Received");
    }


    // Set up the payload
    try {
        PayloadDecoder<SparkplugBPayload> decoder = new SparkplugBPayloadDecoder();
        SparkplugBPayload incomingPayload = decoder.buildFromByteArray(messages.get(position).getMessage().getPayload());

        TextView payloadTextView = (TextView) rowView.findViewById(R.id.message_payload_text);

        StringBuilder sb = new StringBuilder();
        for (Metric metric : incomingPayload.getMetrics()) {
            sb.append(metric.getName()).append("=").append(metric.getValue()).append("   ");
        }

        payloadTextView.setText(sb.toString());
    } catch (Exception e) {
        Log.d(TAG, "Failed to parse out payload", e);
    }

    TextView dateTextView = (TextView) rowView.findViewById(R.id.message_date_text);
    DateFormat dateTimeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
    String shortDateStamp = dateTimeFormatter.format(messages.get(position).getTimestamp());
    dateTextView.setText(context.getString(R.string.message_time_fmt, shortDateStamp));

    return rowView;
}
 
示例20
public void findViewById(View v) {
    homepage = (LinearLayout) v.findViewById(R.id.me_homepage);
    comment = (LinearLayout) v.findViewById(R.id.me_item_comment);
    record = (LinearLayout) v.findViewById(R.id.me_item_reord);
    favor = (LinearLayout) v.findViewById(R.id.me_item_favor);

    usernameTV = (TextView) v.findViewById(R.id.me_homepage_username);
    exerciseTimeTextView = (TextView) v.findViewById(R.id.me_exercise_time);
    recordDaysTextView = (TextView) v.findViewById(R.id.me_record_days);
    exit = (TextView) v.findViewById(R.id.me_item_exit);
}
 
示例21
@Override
public View getGroupView(int listPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
    String listTitle = (String) getGroup(listPosition);
    if (convertView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) this.context.
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(R.layout.list_group, null);
    }
    TextView listTitleTextView = (TextView) convertView
            .findViewById(R.id.listTitle);
    listTitleTextView.setTypeface(null, Typeface.BOLD);
    listTitleTextView.setText(listTitle);
    return convertView;
}
 
示例22
@Override protected void onFinishInflate() {
  super.onFinishInflate();
  modifierTitle = (TextView) findViewById(R.id.bike_image_modifier_title);
  textSwitcher = (TextSwitcher) findViewById(R.id.text_switcher);
  textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
    @Override public View makeView() {
      return LayoutInflater.from(getContext()).inflate(R.layout.modifier_value_textview, null);
    }
  });
}
 
示例23
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View view = getActivity().getLayoutInflater().inflate(R.layout.managegroupactivity_list_item_layout, parent,
            false);
    TextView tv = (TextView) view;
    tv.setBackgroundColor(defaultBG);
    if (getListView().getCheckedItemPositions().get(position)) {
        tv.setBackgroundColor(checkedBG);
    }
    tv.setText(name.get(position));
    return view;
}
 
示例24
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_left_drawer_layout);

    mLeftDrawerLayout = (LeftDrawerLayout) findViewById(R.id.id_drawerlayout);
    mContentTv = (TextView) findViewById(R.id.id_content_tv);

    FragmentManager fm = getSupportFragmentManager();
    mMenuFragment = (LeftMenuFragment) fm.findFragmentById(R.id.id_container_menu);
    if (mMenuFragment == null)
    {
        fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment = new LeftMenuFragment()).commit();
    }

    mMenuFragment.setOnMenuItemSelectedListener(new LeftMenuFragment.OnMenuItemSelectedListener()
    {
        @Override
        public void menuItemSelected(String title)
        {
            mLeftDrawerLayout.closeDrawer();
            mContentTv.setText(title);
        }
    });

}
 
示例25
/**
 * Loads view from resources
 * @param resource the resource Id
 * @return the loaded view or null if resource is not set
 */
private View getView(int resource, ViewGroup parent) {
    switch (resource) {
    case NO_RESOURCE:
        return null;
    case TEXT_VIEW_ITEM_RESOURCE:
        return new TextView(context);
    default:
        return inflater.inflate(resource, parent, false);    
    }
}
 
示例26
public View.OnClickListener stop(final TextView status, final EditText editText) {
    return new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Proxysdk.stop((serviceID));
            editText.setEnabled(true);
            status.setText(R.string.stopped);
        }
    };
}
 
示例27
private static void addDetectedValueHeader(@NonNull ListView listView, @StringRes int labelRes, @NonNull String labelKey, @NonNull String labelValue, @NonNull String value, @NonNull Icon icon) {
    final TextView textView = (TextView) LayoutInflater.from(listView.getContext()).inflate(R.layout.edx_selectable_list_item, listView, false);
    {
        final SpannableString labelValueSpan = new SpannableString(labelValue);
        labelValueSpan.setSpan(new ForegroundColorSpan(listView.getResources().getColor(R.color.edx_brand_gray_base)), 0, labelValueSpan.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(ResourceUtil.getFormattedString(listView.getContext().getResources(), labelRes, labelKey, labelValueSpan));
    }
    Context context = textView.getContext();
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            new IconDrawable(context, icon)
                    .sizeRes(context, R.dimen.edx_base)
                    .colorRes(context, R.color.edx_brand_gray_back)
            , null, null, null);
    listView.addHeaderView(textView, new FormOption(labelValue, value), true);
}
 
示例28
PhoneNumberUi(View root, String activityTitle) {
    title = (TextView) root.findViewById(R.id.phone_number_title);
    phoneField = (EditText) root.findViewById(R.id.phone_number_field);
    submit = (Button) root.findViewById(R.id.phone_number_submit);
    phoneFocus = new FocusControl(phoneField);

    title.setText(activityTitle);
    submit.setOnClickListener(this);
    phoneField.setOnClickListener(this);
    setSubmitEnabled(true);
}
 
示例29
public static Matcher<View> withoutCompoundDrawable(final int position) {
  return new BoundedMatcher<View, TextView>(TextView.class) {
    @Override public void describeTo(Description description) {
      description.appendText(
          "does not have compound drawable at position " + position);
    }
    @Override public boolean matchesSafely(TextView textView) {
      Drawable drawables[] = textView.getCompoundDrawables();
      return (drawables[position] == null);
    }
  };
}
 
示例30
@SuppressLint("InflateParams")
@Override
public View getView(int position, View view, ViewGroup arg2) {
	// TODO Auto-generated method stub

	ViewHolder viewholder;
	if (view == null) {
		view = mInflater.inflate(R.layout.item_devicelist, null);
		viewholder = new ViewHolder();
		viewholder.devicename = (TextView) view
				.findViewById(R.id.tv_devicelist_name);
		viewholder.deviceAddress = (TextView) view
				.findViewById(R.id.tv_devicelist_address);
		viewholder.deviceRSSI = (TextView) view
				.findViewById(R.id.tv_devicelist_rssi);
		viewholder.devicerecord = (TextView) view
				.findViewById(R.id.tv_devicelist_scanRecord);
		viewholder.devicerecord_name = (TextView) view
				.findViewById(R.id.tv_devicelist_scanRecord_name);
		view.setTag(viewholder);
	} else {
		viewholder = (ViewHolder) view.getTag();
	}
	String name = mLeDevices.get(position).getName();
	if (name != null)
		viewholder.devicename.setText(name);
	else
		viewholder.devicename.setText("Unknow Device");
	viewholder.deviceAddress.setText("��ַ�� "
			+ mLeDevices.get(position).getAddress());
	viewholder.deviceRSSI.setText("�źţ� " + RSSIs.get(position).toString());
	viewholder.devicerecord.setText("�㲥���� " + "\n"
			+ scanRecords.get(position));
	viewholder.devicerecord_name.setText("�㲥���е�����:"
			+ Utils.ParseScanRecord(scanRecords.get(position)));
	return view;
}