Example usage for android.widget TextView setText

List of usage examples for android.widget TextView setText

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setText(@StringRes int resid) 

Source Link

Document

Sets the text to be displayed using a string resource identifier.

Usage

From source file:gov.wa.wsdot.android.wsdot.ui.FacebookFragment.java

public void onLoadFinished(Loader<ArrayList<FacebookItem>> loader, ArrayList<FacebookItem> data) {

    if (!data.isEmpty()) {
        mAdapter.setData(data);/*from   ww  w .  j a  va2s .co  m*/
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:mobisocial.musubi.objects.PictureObj.java

@Override
public void render(Context context, View view, DbObjCursor obj, boolean allowInteractions) {
    LinearLayout frame = (LinearLayout) view;

    ImageView imageView = (ImageView) frame.getChildAt(0);
    FileDescriptor fd = obj.getFileDescriptorForRaw();
    byte[] raw = null;
    if (fd == null) {
        raw = obj.getRaw();//from   w w  w . j a v  a 2 s  .c om
    }

    bindImageToView(context, imageView, raw, fd);

    String text = obj.getJson().optString(TEXT);
    TextView textView = (TextView) frame.getChildAt(1);
    textView.setText(text);
}

From source file:id.zelory.tanipedia.activity.BeritaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_berita);
    toolbar = (Toolbar) findViewById(R.id.anim_toolbar);

    setSupportActionBar(toolbar);//from  w  ww  .j a  va 2 s. c  o  m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Berita Terbaru");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);

    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer);
    setUpNavDrawer();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.getMenu().getItem(1).setChecked(true);
    TextView nama = (TextView) navigationView.findViewById(R.id.nama);
    nama.setText(PrefUtils.ambilString(this, "nama"));
    TextView email = (TextView) navigationView.findViewById(R.id.email);
    email.setText(PrefUtils.ambilString(this, "email"));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            Intent intent;
            switch (menuItem.getItemId()) {
            case R.id.cuaca:
                intent = new Intent(BeritaActivity.this, CuacaActivity.class);
                break;
            case R.id.berita:
                return true;
            case R.id.tanya:
                intent = new Intent(BeritaActivity.this, TanyaActivity.class);
                break;
            case R.id.harga:
                intent = new Intent(BeritaActivity.this, KomoditasActivity.class);
                break;
            case R.id.logout:
                PrefUtils.simpanString(BeritaActivity.this, "nama", null);
                intent = new Intent(BeritaActivity.this, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                return true;
            case R.id.tentang:
                intent = new Intent(BeritaActivity.this, TentangActivity.class);
                startActivity(intent);
                return true;
            default:
                return true;
            }
            startActivity(intent);
            finish();
            return true;
        }
    });
    imageHeader = (ImageView) findViewById(R.id.header);
    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);

    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:gov.wa.wsdot.android.wsdot.ui.SeattleExpressLanesFragment.java

public void onLoadFinished(Loader<ArrayList<ExpressLaneItem>> loader, ArrayList<ExpressLaneItem> data) {

    if (!data.isEmpty()) {
        adapter.setData(data);//www. ja  va  2s.c o  m
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:com.brodev.socialapp.view.VideoPlay.java

/** This method initialise all the views in project */
private void initView() {
    // set song name
    TextView songName = (TextView) findViewById(R.id.songName);
    songName.setText(video.getTitle());
    colorView.changeColorText(songName, user.getColor());

    // set short text
    TextView shortText = (TextView) findViewById(R.id.shortText);
    shortText.setText(video.getFull_name());

    TextView time_stamp = (TextView) findViewById(R.id.time_stamp);
    time_stamp.setText(video.getTime_stamp());
    TextView total_like = (TextView) findViewById(R.id.total_like);
    total_like.setText(String.valueOf(video.getTotal_like()));
    colorView.changeColorText(total_like, user.getColor());

    TextView total_comment = (TextView) findViewById(R.id.total_comment);
    total_comment.setText(String.valueOf(video.getTotal_comment()));
    colorView.changeColorText(total_comment, user.getColor());

    TextView content = (TextView) findViewById(R.id.videoContent);
    content.setText(video.getText());//  w  ww . j  a  v a2s.  c om

    ImageView likeImg = (ImageView) this.findViewById(R.id.likes_feed_txt);
    ImageView commentImg = (ImageView) this.findViewById(R.id.comments_feed_txt);
    colorView.changeColorLikeCommnent(likeImg, commentImg, user.getColor());

    ImageView videoImage = (ImageView) findViewById(R.id.videoImage);
    if (video.isYoutube()) {
        networkUntil.drawImageUrl(videoImage, video.GetBigImage(), R.drawable.loading);
    } else {
        networkUntil.drawImageUrl(videoImage, video.getImage_path(), R.drawable.loading);
    }

    if (!video.getDuration().equals("")) {
        TextView duration = (TextView) findViewById(R.id.duration);
        duration.setText(video.getDuration());
    }

    // set User image
    ImageView userImage = (ImageView) findViewById(R.id.image_user);
    networkUntil.drawImageUrl(userImage, video.getUser_image_path(), R.drawable.loading);
    userImage.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Intent intent = new Intent(VideoPlay.this, FriendTabsPager.class);
            intent.putExtra("user_id", video.getUser_id());
            startActivity(intent);
            return false;
        }
    });

    videoImage.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (video.isYoutube()) {
                String videoId = video.getTubeId();
                Intent lVideoIntent = new Intent(null, Uri.parse("ytv://" + videoId), getApplicationContext(),
                        OpenYouTubePlayerActivity.class);
                startActivity(lVideoIntent);
            } else {
                Intent intent = new Intent(getApplicationContext(), WebviewActivity.class);
                Log.i("CHECKLINK", video.getWeb_link());
                intent.putExtra("html", video.getWeb_link());

                startActivity(intent);
            }

            return false;
        }
    });

}

From source file:com.savedollars.ProductShippingPriceDisplay.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites()
            .detectNetwork().penaltyLog().build());

    JSONData = (getIntent().getStringExtra("JsonData"));
    if (JSONData != null) {
        parseJsonData(JSONData);//  w w  w .j  a  v a 2  s. c om
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pdtshippingpriceview);

    // Setting Product Name
    TextView productName = (TextView) findViewById(R.id.pdtNameTextView);
    productName.setText(pdtName);

    Iterator objMapIterator = sortedMap.entrySet().iterator();
    int rowIndex = 0;

    PDT_INFO = new String[totalCount][2];
    while (objMapIterator.hasNext()) {
        Map.Entry keyValuePairs = (Map.Entry) objMapIterator.next();
        String key = ProductTotalPriceDisplay.merchantNames[rowIndex];

        PDT_INFO[rowIndex][0] = key;
        PDT_INFO[rowIndex][1] = "$" + String.valueOf(sortedMap.get(key));
        rowIndex++;
    }

    ListViewAdapter listv = new ListViewAdapter(this, PDT_INFO);

    setListAdapter(listv);

    final ListView lv = getListView();

    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            lv.getItemAtPosition(position);
            String pdtKey = PDT_INFO[position][0];
            String merchantLink = (String) merchantLinkMap.get(pdtKey);

            Uri uri = Uri.parse(merchantLink);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);

        }
    });
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public void buildSurveyName(Survey survey, ViewGroup parent) {

    ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.survey_layout, parent);
    TextView name = (TextView) row.findViewById(R.id.surveyName);
    name.setText(survey.name);/* w ww  . ja  v a 2  s .c  o m*/
    name.setFocusableInTouchMode(true);
    name.setFocusable(true);
    TextView description = (TextView) row.findViewById(R.id.surveyDescription);
    description.setText(survey.description);

}

From source file:net.olejon.mdapp.LvhCategoriesAdapter.java

@Override
public void onBindViewHolder(CategoryViewHolder viewHolder, int i) {
    try {//from w  w  w  .  ja va2  s. com
        final JSONObject categoriesJsonObject = mCategories.getJSONObject(i);

        viewHolder.card.setCardBackgroundColor(Color.parseColor(mColor));

        switch (mIcon) {
        case "lvh_urgent": {
            viewHolder.icon.setImageResource(R.drawable.ic_favorite_white_24dp);
            break;
        }
        case "lvh_symptoms": {
            viewHolder.icon.setImageResource(R.drawable.ic_stethoscope);
            break;
        }
        case "lvh_injuries": {
            viewHolder.icon.setImageResource(R.drawable.ic_healing_white_24dp);
            break;
        }
        case "lvh_administrative": {
            viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp);
            break;
        }
        }

        viewHolder.title.setText(categoriesJsonObject.getString("title"));

        viewHolder.categories.removeAllViews();

        final JSONArray itemsJsonArray = categoriesJsonObject.getJSONArray("items");

        for (int f = 0; f < itemsJsonArray.length(); f++) {
            final JSONObject categoryJsonObject = itemsJsonArray.getJSONObject(f);

            final String name = categoryJsonObject.getString("name");
            final String uri = categoryJsonObject.getString("uri");

            TextView textView = (TextView) mLayoutInflater
                    .inflate(R.layout.activity_lvh_categories_card_categories_item, null);
            textView.setText(name);

            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, MainWebViewActivity.class);
                    intent.putExtra("title", name);
                    intent.putExtra("uri", uri);
                    mContext.startActivity(intent);
                }
            });

            viewHolder.categories.addView(textView);
        }

        animateView(viewHolder.card, i);
    } catch (Exception e) {
        Log.e("LvhCategoriesAdapter", Log.getStackTraceString(e));
    }
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public View buildLabel(Attribute attribute, ViewGroup parent) {
    ViewGroup view = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.label_text_view, parent);
    TextView textView = (TextView) view.findViewById(R.id.fieldLabel);

    textView.setText(Utils.bold(attribute.description));
    return view;//from www. ja  va 2 s  .co m
}

From source file:de.uhrenbastler.watchcheck.ui.LogDialog.java

public LogDialog(Context context, Bundle logData) {
    super(context);

    setContentView(R.layout.log_dialog);
    setTitle(getContext().getString(R.string.enterLog));
    setCancelable(true);//from   ww  w  . j av  a2  s.c  om

    Button buttonSave = (Button) findViewById(R.id.buttonSave);
    buttonSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            makeLogEntry();
            saved = true;
            dismiss();
        }
    });

    watchId = logData.getInt(ATTR_WATCH_ID);
    deviation = logData.getDouble(ATTR_DEVIATION);
    modeNtp = logData.getBoolean(ATTR_MODE_NTP);
    localTime = (GregorianCalendar) logData.get(ATTR_LOCAL_TIME);
    ntpTime = (GregorianCalendar) logData.get(ATTR_NTP_TIME);
    lastLog = (Log) logData.get(ATTR_LAST_LOG);

    Logger.debug("watchId=" + watchId + ", deviation=" + deviation + ", modeNtp=" + modeNtp + ", localTime="
            + localTime.getTime() + ", ntpTime=" + (ntpTime != null ? ntpTime.getTime() : "NULL") + ", lastLog="
            + lastLog);

    TextView textDeviation = (TextView) findViewById(R.id.textViewDeviationValue);
    DecimalFormat df = new DecimalFormat("#.#");

    textDeviation.setText(
            (deviation > 0 ? "+" : deviation < 0 ? "-" : "+-") + df.format(Math.abs(deviation)) + " sec.");

    positionSpinner = (Spinner) findViewById(R.id.logSpinnerPosition);
    ArrayAdapter<?> positionAdapter = ArrayAdapter.createFromResource(getContext(), R.array.positions,
            android.R.layout.simple_spinner_item);
    positionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    positionSpinner.setAdapter(positionAdapter);

    if (lastLog != null && lastLog.getPosition() != null)
        positionSpinner.setSelection(ArrayUtils.indexOf(POSITIONARR, lastLog.getPosition()));
    else
        positionSpinner.setSelection(0);

    temperatureSpinner = (Spinner) findViewById(R.id.logSpinnerTemperature);
    ArrayAdapter<?> temperatureAdapter = ArrayAdapter.createFromResource(getContext(), R.array.temperatures,
            android.R.layout.simple_spinner_item);
    temperatureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    temperatureSpinner.setAdapter(temperatureAdapter);

    if (lastLog != null)
        temperatureSpinner.setSelection(ArrayUtils.indexOf(TEMPARR, lastLog.getTemperature()));
    else
        temperatureSpinner.setSelection(0);

    comment = (EditText) findViewById(R.id.logComment);

    startFlag = (CheckBox) findViewById(R.id.logCheckBoxNewPeriod);
    startFlag.setChecked(lastLog == null);
    startFlag.setEnabled(lastLog != null);
}