// Get our EditText object.
EditText vw = (EditText)findViewById(R.id.text);
// Set the EditText's text.
vw.setText("Italic, highlighted, bold.");
// If this were just a TextView, we could do:
// vw.setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE);
// to force it to use Spannable storage so styles can be attached.
// Or we could specify that in the XML.
// Get the EditText's internal text storage
Spannable str = vw.getText();
// Create our span sections, and assign a format to each.
str.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str.setSpan(new BackgroundColorSpan(0xFFFFFF00), 8, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 21, str.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
http://developer.android.com/intl/zh-CN/guide/appendix/faq/commontasks.html
或者
mBox = new TextView(context); mBox.setText(Html.fromHtml("<b>" + title + "</b>" + "<br />" + "<small>" + description + "</small>" + "<br />" + "<small>" + DateAdded + "</small>");
想在listView中使用超链接 可以继承custom adapter并在getView
textcontent.setText(Html.fromHtml(item.get_text()));
textcontent.setAutoLinkMask(Linkify.WEB_URLS);
然后在
<TextView
android:id="@+id/txtview"
android:autoLink="web"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="put your link here"/>
下标:
mtTextView.setText(Html.fromHtml("HC0<sub>3</sub>"));
1.更换hendler
mSlidingDrawer.setOnDrawerScrollListener(new OnDrawerScrollListener(){
@Override
public void onScrollEnded() {
// TODO Auto-generated method stub
Log.i("ddd","onScrollEnded slider");
slider_animation.reverseTransition(HANDLE_ANIMATION_SPEED);
}
@Override
public void onScrollStarted() {
// TODO Auto-generated method stub
Log.i("ddd","onScrollStarted slider");
slider_animation.startTransition(HANDLE_ANIMATION_SPEED);
}});
要在上面的函数执行 不能
ImageView handle = (ImageView)findViewById(R.id.handle_l);
handle.setFocusable(true);
handle.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("test","onClick"); } });
在listView中或其他格式中存在editView,尤其是listView和editView并存的时候 程序运行veditvview 就获得焦点,如何让他不获得焦点呢
EditText.setSelected(false);
上述命令是不行的。
clearFocus() 才是可以的。
如果你是用AutoCompleteTextView
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
android:focusable="true" android:focusableInTouchMode="true"
android:layout_width="0px" android:layout_height="0px"/>
<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="@+id/text"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:nextFocusUp="@+id/text" android:nextFocusLeft="@+id/text"/>