Java Code Examples for android.widget.TextView.append()

The following are Jave code examples for showing how to use append() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: yyox   File: CustomTextView.java   View Source Code Vote up 6 votes
/**
 * 解析link
 *
 * @param tv_content
 * @param context
 */
private static void dealUnderLinesData(TextView tv_content, Context context) {
    CharSequence charSequence = tv_content.getText();
    if (charSequence instanceof Spannable) {
        tv_content.setText("");
        Spannable s = EmojiDisplay.spannableFilter(tv_content.getContext(),
                new SpannableStringBuilder(charSequence),
                charSequence,
                EmoticonsKeyboardUtils.getFontHeight(tv_content));
        URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
        for (URLSpan span : spans) {
            int start = s.getSpanStart(span);
            int end = s.getSpanEnd(span);
            String clickText = s.subSequence(start, end).toString();
            URLSpanNoUnderline urlSpanNoUnderline = new URLSpanNoUnderline(context, span.getURL(), clickText);
            s.setSpan(urlSpanNoUnderline, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        tv_content.append(s);
    }
}
 
Example 2
Project: SSLSocks   File: LogFragment.java   View Source Code Vote up 6 votes
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
	final TextView logText = (TextView) view.findViewById(R.id.logtext);
	IntentFilter statusIntentFilter = new IntentFilter(ServiceUtils.ACTION_LOGBROADCAST);
	BroadcastReceiver statusReceiver = new BroadcastReceiver() {
		@Override
		public void onReceive(Context context, Intent intent) {
			if (intent.hasExtra(ServiceUtils.EXTENDED_DATA_LOG)) {
				logText.append("\n");
				logText.append(intent.getStringExtra(ServiceUtils.EXTENDED_DATA_LOG));
				Log.d("received", intent.getStringExtra(ServiceUtils.EXTENDED_DATA_LOG));
			}
		}
	};
	LocalBroadcastManager.getInstance(getActivity()).registerReceiver(statusReceiver, statusIntentFilter);
}
 
Example 3
Project: weex-3d-map   File: SupplementalInfoRetriever.java   View Source Code Vote up 6 votes
@Override
protected final void onPostExecute(Object arg) {
  TextView textView = textViewRef.get();
  if (textView != null) {
    for (CharSequence content : newContents) {
      textView.append(content);
    }
    textView.setMovementMethod(LinkMovementMethod.getInstance());
  }
  HistoryManager historyManager = historyManagerRef.get();
  if (historyManager != null) {
    for (String[] text : newHistories) {
      historyManager.addHistoryItemDetails(text[0], text[1]);
    }
  }
}
 
Example 4
Project: android-dev-challenge   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // COMPLETED (3) Use findViewById to get a reference to the TextView from the layout
    mToysListTextView = (TextView) findViewById(R.id.tv_toy_names);

    // COMPLETED (4) Use the static ToyBox.getToyNames method and store the names in a String array
    String toyNames[] = ToyBox.getToyNames();

    // COMPLETED (5) Loop through each toy and append the name to the TextView (add \n for spacing)
    for(String toyName:toyNames) {
        mToysListTextView.append(toyName + "\n\n\n");
    }
}
 
Example 5
Project: buildAPKsSamples   File: ReceiveShare.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.receive_share);

    Button sendButton = (Button)findViewById(R.id.send_to_service);
    final Uri uri = getShareUri(getIntent());
    if (uri != null) {
        sendButton.setEnabled(true);
    } else {
        sendButton.setEnabled(false);
    }

    TextView content = (TextView)findViewById(R.id.receive_share_data);
    content.append(buildShareInfo(getContentResolver(), getIntent()));

    // Watch for button clicks.
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ReceiveShare.this, ReceiveShareService.class);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            ClipData clip = ClipData.newUri(getContentResolver(), "Something", uri);
            intent.setClipData(clip);
            startService(intent);
            finish();
        }
    });
}
 
Example 6
Project: TextBuilder   File: TextBuilder.java   View Source Code Vote up 5 votes
public void into(@NonNull final TextView textView) {
  checkNotNull(textView, "textView == null");

  for (final Spannable spannable : spannables) {
    textView.append(spannable);
  }
}
 
Example 7
Project: InstantUpload   File: StorageInfo.java   View Source Code Vote up 5 votes
void line (TextView tv)
   {
String temp;

switch (storageType) {
    case 0: temp = "undefined"; break;
    case 1: temp = "Fixed ROM"; break;
    case 2: temp = "Removable ROM"; break;
    case 3: temp = "Fixed RAM"; break;
    case 4: temp = "Removable RAM"; break;
    default:
	temp = "Reserved-0x" + Integer.toHexString (storageType);
}
tv.append  ("Storage Type: " + temp +" \n");
   }
 
Example 8
Project: MRouter   File: DActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_range_layout);
    TextView textView = (TextView) findViewById(R.id.text_name);
    textView.setText("D");
    findViewById(R.id.btn_start_activity).setVisibility(View.GONE);

    findViewById(R.id.btn_finish_range_by_class).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_range_begin_router_path1).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_range_begin_router_path2).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_range_begin_router_path3).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_start_to).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_start_to_by_router_path).setVisibility(View.VISIBLE);

    findViewById(R.id.btn_finish_top_activity).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_activity_by_class).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_activity_by_router_path).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_activity).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_activity_except_activity_class).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_activity_except_router_path).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_activity_except_by_list).setVisibility(View.VISIBLE);
    findViewById(R.id.btn_finish_all_activity_by_list).setVisibility(View.VISIBLE);


    int count = RouterActivityManager.get().getActivityCount();
    textView.append("\n\nactivity count:");
    textView.append("" + count);
}
 
Example 9
Project: ZXingAndroidExt   File: SupplementalInfoRetriever.java   View Source Code Vote up 5 votes
@Override
protected final void onPostExecute(Object arg) {
    TextView textView = textViewRef.get();
    if (textView != null) {
        for (CharSequence content : newContents) {
            textView.append(content);
        }
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
 
Example 10
Project: UnversityFinance   File: MyAsyncTask.java   View Source Code Vote up 5 votes
private TextView createNoticeView(BannerBean content) {
    TextView view = new TextView(mContext);
    view.setText(content.getTitle());
    view.append("\n");
    view.append(content.getTitle2());
    view.setTextColor(mContext.getResources().getColor(R.color.color_text));
    view.setGravity(Gravity.CENTER_VERTICAL);

    return view;
}
 
Example 11
Project: MyBP   File: Span.java   View Source Code Vote up 5 votes
public static void span(String text, TextView textView) {
    SpannableString spanText = new SpannableString(text);
    spanText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, text.length(), 0);
    spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0);

    textView.setText("");
    textView.append(spanText);
}
 
Example 12
Project: SuperNote   File: RvNoteListAdapter.java   View Source Code Vote up 5 votes
/**
 *   解析文本中的图片
 */
private void parseTextContent(TextView textView, String content) {
    // TODO: 2017/7/11 0011 后续可以找到图片后,显示在列表item上 

    textView.setText("");

    Pattern p = Pattern.compile(EditNoteConstans.imageTabBefore+"([^<]*)"+EditNoteConstans.imageTabAfter);
    Matcher m = p.matcher(content);
    int tempIndex = 0;
    List<String> textList=new ArrayList<>();
    while (m.find()) {
        
        //  匹配到的数据中,第一个括号的中的内容(这里只有一个括号)
        String temp = m.group(1);
        
        //  查找图片标签的位置
        int index = content.indexOf(EditNoteConstans.imageTabBefore, tempIndex);
        
        //  将本次开始位置到图片标签间的图片储存起来
        String text = content.substring(tempIndex, index);
        textList.add(text);
        
        // 将查询起始位置升级
        int flagLength=EditNoteConstans.imageTabBefore.length()+EditNoteConstans.imageTabAfter.length();
        tempIndex = index + flagLength + temp.length();
    }

    if(textList.size()!=0){
        for (int i=0;i<textList.size();i++){
            textView.append(textList.get(i));
            textView.append("[图片]");
        }
        // 将最后一个图片标签后面所有的文字添加
        textView.append(content.substring(tempIndex));
    }else{
        textView.setText(content);
    }
}
 
Example 13
Project: android-dev-challenge   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /*
     * Using findViewById, we get a reference to our TextView from xml. This allows us to
     * do things like set the text of the TextView.
     */
    mToysListTextView = (TextView) findViewById(R.id.tv_toy_names);

    /*
     * This String array contains names of classic toys. After all, these are toy apps. We
     * wanted to create a way to break concepts down into smaller pieces that we thought might
     * be a little easier to understand. In each lesson, we'll demonstrate new concepts using a
     * toy app (no, sadly every one won't have ACTUAL toys in it) and then we'll guide you
     * through adding the functionality that you've just learned by having you use those
     * concepts in Sunshine! Let us know what you think! We're really excited to have you
     * taking this course.
     */
    String[] toyNames = ToyBox.getToyNames();

    /*
     * Iterate through the array and append the Strings to the TextView. The reason why we add
     * the "\n\n\n" after the String is to give visual separation between each String in the
     * TextView. Later, we'll learn about a better way to display lists of data.
     */
    for (String toyName : toyNames) {
        mToysListTextView.append(toyName + "\n\n\n");
    }
}
 
Example 14
Project: android-dev-challenge   File: MainActivity.java   View Source Code Vote up 5 votes
/**
 * Called when the activity is first created. This is where you should do all of your normal
 * static set up: create views, bind data to lists, etc.
 * <p>
 * Always followed by onStart().
 *
 * @param savedInstanceState The Activity's previously frozen state, if there was one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLifecycleDisplay = (TextView) findViewById(R.id.tv_lifecycle_events_display);

    /*
     * If savedInstanceState is not null, that means our Activity is not being started for the
     * first time. Even if the savedInstanceState is not null, it is smart to check if the
     * bundle contains the key we are looking for. In our case, the key we are looking for maps
     * to the contents of the TextView that displays our list of callbacks. If the bundle
     * contains that key, we set the contents of the TextView accordingly.
     */
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(LIFECYCLE_CALLBACKS_TEXT_KEY)) {
            String allPreviousLifecycleCallbacks = savedInstanceState
                    .getString(LIFECYCLE_CALLBACKS_TEXT_KEY);
            mLifecycleDisplay.setText(allPreviousLifecycleCallbacks);
        }
    }

    // COMPLETED (4) Iterate backwards through mLifecycleCallbacks, appending each String and a newline to mLifecycleDisplay
    for (int i = mLifecycleCallbacks.size() - 1; i >= 0; i--) {
        mLifecycleDisplay.append(mLifecycleCallbacks.get(i) + "\n");
    }
    // COMPLETED (5) Clear mLifecycleCallbacks after iterating through it
    mLifecycleCallbacks.clear();

    logAndAppend(ON_CREATE);
}
 
Example 15
Project: android-dev-challenge   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_forecast);

    // COMPLETED (2) Use findViewById to get a reference to the weather display TextView
    mWeatherTextView = (TextView) findViewById(R.id.tv_weather_data);

    // COMPLETED (3) Create an array of Strings that contain fake weather data
    String[] dummyWeatherData = {
            "Today, May 17 - Clear - 17°C / 15°C",
            "Tomorrow - Cloudy - 19°C / 15°C",
            "Thursday - Rainy- 30°C / 11°C",
            "Friday - Thunderstorms - 21°C / 9°C",
            "Saturday - Thunderstorms - 16°C / 7°C",
            "Sunday - Rainy - 16°C / 8°C",
            "Monday - Partly Cloudy - 15°C / 10°C",
            "Tue, May 24 - Meatballs - 16°C / 18°C",
            "Wed, May 25 - Cloudy - 19°C / 15°C",
            "Thu, May 26 - Stormy - 30°C / 11°C",
            "Fri, May 27 - Hurricane - 21°C / 9°C",
            "Sat, May 28 - Meteors - 16°C / 7°C",
            "Sun, May 29 - Apocalypse - 16°C / 8°C",
            "Mon, May 30 - Post Apocalypse - 15°C / 10°C",
    };

    // COMPLETED (4) Append each String from the fake weather data array to the TextView
    for (String dummyWeatherDay : dummyWeatherData) {
        mWeatherTextView.append(dummyWeatherDay + "\n\n\n");
    }
}
 
Example 16
Project: Small-Android-apps   File: MainActivity.java   View Source Code Vote up 5 votes
/**
 * Called when the activity is first created. This is where you should do all of your normal
 * static set up: create views, bind data to lists, etc.
 * <p>
 * Always followed by onStart().
 *
 * @param savedInstanceState The Activity's previously frozen state, if there was one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLifecycleDisplay = (TextView) findViewById(R.id.tv_lifecycle_events_display);

    /*
     * If savedInstanceState is not null, that means our Activity is not being started for the
     * first time. Even if the savedInstanceState is not null, it is smart to check if the
     * bundle contains the key we are looking for. In our case, the key we are looking for maps
     * to the contents of the TextView that displays our list of callbacks. If the bundle
     * contains that key, we set the contents of the TextView accordingly.
     */
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(LIFECYCLE_CALLBACKS_TEXT_KEY)) {
            String allPreviousLifecycleCallbacks = savedInstanceState
                    .getString(LIFECYCLE_CALLBACKS_TEXT_KEY);
            mLifecycleDisplay.setText(allPreviousLifecycleCallbacks);
        }
    }

    // TODO (4) Iterate backwards through mLifecycleCallbacks, appending each String and a newline to mLifecycleDisplay

    for(int i=mLifecycleCallbacks.size() - 1; i >= 0; i--){
        mLifecycleDisplay.append(mLifecycleCallbacks.get(i));
    }

    mLifecycleCallbacks.clear();

    // TODO (5) Clear mLifecycleCallbacks after iterating through it

    logAndAppend(ON_CREATE);
}
 
Example 17
Project: Microsphere   File: MainActivity.java   View Source Code Vote up 4 votes
public void add_log(String line) {
    TextView tv = (TextView) findViewById(R.id.sample_text);
    tv.append("\n" + line);
}
 
Example 18
Project: Library-System-Android   File: CancelHold.java   View Source Code Vote up 4 votes
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub

    if (arg0.getId() == R.id.transactions_spinner) {
        System.out.println("IN HERE TESTTEST" + userRentals.toString());
        Object item = arg0.getItemAtPosition(arg2);
        String test = item.toString();


        for(int i=0; i<userRentals.size(); i++){

        String compare = userRentals.get(i).getId()+ " " + userRentals.get(i).getTitle() +"Date: "+ userRentals.get(i).getDate();

            System.out.println("COMPARE TESTTEST " +i+ ": |" + compare + "| Item: |" +  item + "|match: " + (compare.equals(test)));

            if(compare.equals(test)){
                TextView main = (TextView) findViewById(R.id.mainText);

                main.setText("");
                main.append("Reservation Number: " + userRentals.get(i).getReservation() + "\n");
                main.append("Title: " + userRentals.get(i).getTitle() + "\n");
                main.append(userRentals.get(i).getType()+"\n");
                main.append("Date: " + userRentals.get(i).getDate() + "\n");
                main.append("Time: " + userRentals.get(i).getTime() + "\n");
                main.append("Pick Up: " + userRentals.get(i).getPickUpDate() + "\n");
                main.append("Return: " + userRentals.get(i).getDropOffDate() + "\n");

                bookToCancel=userRentals.get(i).getTitle();

                pickUpDay=userRentals.get(i).getPickDayYear();
                dropDay=userRentals.get(i).getDropDayYear();

                //userRentals.get(i).setActive(0);
                //db.updateTransaction(new Transaction(userRentals.get(i)));

                transactionID = userRentals.get(i).getId();
            }
        }
    }
}
 
Example 19
Project: InstantUpload   File: StorageInfo.java   View Source Code Vote up 4 votes
void showInTextView (TextView tv)
   {
String temp;


tv.setText ("StorageInfo:");
tv.append  ("\n");
line (tv);

switch (filesystemType) {
    case 0: temp = "undefined"; break;
    case 1: temp = "flat"; break;
    case 2: temp = "hierarchical"; break;
    case 3: temp = "dcf"; break;
    default:
	if ((filesystemType & 0x8000) != 0)
	    temp = "Reserved-0x";
	else
	    temp = "Vendor-0x";
	temp += Integer.toHexString (filesystemType);
}
tv.append  ("\n");
tv.append ("Filesystem Type: " + temp);

// access: rw, ro, or ro "with object deletion"

// CF card sizes are "marketing megabytes", not real ones
if (maxCapacity != ~0)
{
	tv.append  ("\n");
	tv.append ("Capacity: "
	+ maxCapacity + " bytes ("
	+ ((maxCapacity + 500000)/1000000) + " MB)"
	);
}
if (freeSpaceInBytes != ~0)
{
	tv.append  ("\n");
	tv.append ("Free space: "
	+ freeSpaceInBytes + " bytes ("
	+ ((freeSpaceInBytes + 500000)/1000000) + " MB)"
	);
}
if (freeSpaceInImages != ~0)
{
	tv.append  ("\n");
	tv.append ("Free space in Images: " + freeSpaceInImages);
}
if (storageDescription != null)
{
	tv.append  ("\n");
	tv.append ("Description: " + storageDescription);
}
if (volumeLabel != null)
{
	tv.append  ("\n");
	tv.append ("Volume Label: " + volumeLabel);
}
   }
 
Example 20
Project: Library-System-Android   File: Confirm.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.confirm);

    //Reservations counter
    ArrayList<Transaction> transactions = new ArrayList<>(db.getAllTransactions());
    for(Transaction transaction : transactions){
        if(transaction.getTypeNumber()==1){reservation++;}
    }

    View test = findViewById(R.id.confirm_button);
    test.setOnClickListener(this);

    TextView main = (TextView) findViewById(R.id.main);

    //***GET PASSED INFO***
    Bundle extras= getIntent().getExtras();
    //PickUp
    String pickUpYear = extras.getString("pickUpYear");
    String pickUpMonth = extras.getString("pickUpMonth");
    String pickUpDay = extras.getString("pickUpDay");
    String pickUpHour = extras.getString("pickUpHour");
    String pickUpAmPm = extras.getString("pickUpAmPm");
    //DropOff
    String dropOffYear = extras.getString("dropOffYear");
    String dropOffMonth = extras.getString("dropOffMonth");
    String dropOffDay = extras.getString("dropOffDay");
    String dropOffHour = extras.getString("dropOffHour");
    String dropOffAmPm = extras.getString("dropOffAmPm");
    //Transaction
    String loggedUsername = extras.getString("username");
    String bookTitle = extras.getString("title");
    double rentalTotal = extras.getDouble("rentalTotal");

    //Transaction Date and time for Pickup
    String pickUpDateTime;
    pickUpDateTime = getMonthNumber(pickUpMonth) +"/" + pickUpDay + "/" + pickUpYear+ " (" + pickUpHour +" "+ pickUpAmPm + ")";
    //Transaction Date and time for Dropoff
    String dropOffDateTime;
    dropOffDateTime = getMonthNumber(dropOffMonth) +"/" + dropOffDay + "/" + dropOffYear + " (" + dropOffHour +" "+ dropOffAmPm + ")";


    //Add info for rental into details box
    NumberFormat formatter = NumberFormat.getCurrencyInstance();
    main.setText("");
    main.append("Username: " + loggedUsername + " \n");
    main.append("Pick Up/Date Time: " + pickUpDateTime + " \n");
    main.append("Return/Date Time: " + dropOffDateTime + " \n");
    main.append("Book Title: " + bookTitle + " \n");
    main.append("Reservation Number: " + (reservation+1) + " \n");
    main.append("Total Rental Cost: " + formatter.format(rentalTotal) + " \n");
}