当前位置: 编程技术>移动开发
本页文章导读:
▪textview加上划线 textview加下划线
如果是在资源文件里,可以这样写
<resources>
<string name="hello"><u>phone: 1390123456</u></string>
<string name="app_name">MyLink</string>
</resources>
如.........
▪ onActivityResult传值的施用 onActivityResult传值的使用
有时候在群里加入的新人总会喜欢问一些过去的问题 有时候不想回答 是因为回答的次数多了
不回答又打击人的积极性 谁让自己接触的早呢 为了省劲还是把简单.........
▪ animation-list旋转的地球以及Timer的施用 animation-list旋转的地球以及Timer的使用
用到animation-list其实就是帧叠加 ,通常要注意两个问题
1.一般布局要用在frameLayout
2.它呢一般作为背景 然后在取出来
public class EarthAnimationActivity extends .........
[1]textview加上划线
来源: 互联网 发布时间: 2014-02-18
textview加下划线
如果是在资源文件里,可以这样写
如果是代码这样写.
这个是eoe社区的人回答的,我还没测试,有空试试~
如果是在资源文件里,可以这样写
<resources>
<string name="hello"><u>phone: 1390123456</u></string>
<string name="app_name">MyLink</string>
</resources>
如果是代码这样写.
TextView textView = (TextView)findViewById(R.id.testView);
textView.setText(Html.fromHtml("<u>"+"hahaha"+"</u>"));
这个是eoe社区的人回答的,我还没测试,有空试试~
1 楼
twins-wolf
2011-02-22
widget中只能使用前者,后者不可以;activity两种方式都能用。
[2] onActivityResult传值的施用
来源: 互联网 发布时间: 2014-02-18
onActivityResult传值的使用
有时候在群里加入的新人总会喜欢问一些过去的问题 有时候不想回答 是因为回答的次数多了
不回答又打击人的积极性 谁让自己接触的早呢 为了省劲还是把简单的东西作为指导篇吧
多个activity之间的传值 其实就是onActivityResult,然后别忘了还有一个action的问题 就是在主xml中添加自己的action以便于识别,最后次activity别忘了finansh。
public class Wizard extends Activity {
private TextView step1result, step2result, step3result;
public static final String INTENT_STEP1 = "com.novoda.STEP1";
public static final String INTENT_STEP2 = "com.novoda.STEP2";
public static final String INTENT_STEP3 = "com.novoda.STEP3";
private static final int STEP1 = 1;
private static final int STEP2 = 2;
private static final int STEP3 = 3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wizard);
this.step1result = (TextView)findViewById(R.id.step1result);
this.step2result = (TextView)findViewById(R.id.step2result);
this.step3result = (TextView)findViewById(R.id.step3result);
startActivityForResult(new Intent(Wizard.INTENT_STEP1), STEP1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case STEP1:
this.step1result.setText(data.getStringExtra("STEP1RESULT"));
startActivityForResult(new Intent(Wizard.INTENT_STEP2), STEP2);
break;
case STEP2:
this.step2result.setText(data.getStringExtra("STEP2RESULT"));
startActivityForResult(new Intent(Wizard.INTENT_STEP3), STEP3);
break;
case STEP3:
this.step3result.setText(data.getStringExtra("STEP3RESULT"));
break;
}
}
}
public class Step1 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.step1);
Button nextStep = (Button)findViewById(R.id.goto2);
nextStep.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent it = new Intent();
it.putExtra("STEP1RESULT", ((EditText)findViewById(R.id.step1value)).getText()
.toString());
setResult(Activity.RESULT_OK, it);
finish();
}
});
}
}
后面的step2 step3都是一样的了
然后还有主xml
<application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Wizard" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Step1" android:label="Step1"> <intent-filter> <action android:name="com.novoda.STEP1" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".Step2" android:label="Step2"> <intent-filter> <action android:name="com.novoda.STEP2" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".Step3" android:label="Step3"> <intent-filter> <action android:name="com.novoda.STEP3" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="7" /> </manifest>
[3] animation-list旋转的地球以及Timer的施用
来源: 互联网 发布时间: 2014-02-18
animation-list旋转的地球以及Timer的使用
用到animation-list其实就是帧叠加 ,通常要注意两个问题
1.一般布局要用在frameLayout
2.它呢一般作为背景 然后在取出来
public class EarthAnimationActivity extends Activity {
private static final String TAG = "EarthAnimationActivity";
protected static final int FORWARD = 0;
protected static final int REVERSE = 1;
private Button earthButton;
private AnimationDrawable earthButtonAnimation;
protected int direction;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
earthButton = (Button) findViewById(R.id.earth_button);
earthButtonAnimation = (AnimationDrawable) earthButton.getBackground();
direction = FORWARD;
earthButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if ( ! earthButtonAnimation.isRunning() ) {
earthButtonAnimation.start();
earthButton.setText(R.string.click_me_to_stop);
}
else {
earthButtonAnimation.stop();
int resId = R.anim.earth_animation_rev;
if ( direction == FORWARD ) {
direction = REVERSE;
}
else {
resId = R.anim.earth_animation;
direction = FORWARD;
}
earthButton.setBackgroundResource(resId);
earthButtonAnimation = (AnimationDrawable) earthButton.getBackground();
earthButton.setText(R.string.click_me_to_start);
}
}
});
}
/* (non-Javadoc)
* @see android.app.Activity#onResume()
*/
@Override
protected void onResume() {
super.onResume();
(new Timer(false)).schedule(new AnimationTimer(earthButtonAnimation), 100);
}
/* (non-Javadoc)
* @see android.app.Activity#onPause()
*/
@Override
protected void onPause() {
super.onPause();
earthButtonAnimation.stop();
}
private static class AnimationTimer extends TimerTask {
AnimationDrawable animation;
public AnimationTimer(AnimationDrawable animation) {
this.animation = animation;
}
@Override
public void run() {
animation.start();
this.cancel();
}
}
}
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/frame_layout" android:background="@drawable/space_background"> <Button android:id="@+id/earth_button" android:background="@anim/earth_animation" android:text="@string/click_me_to_stop" android:layout_gravity="center" android:text android:textColor="#ff9900" android:layout_marginBottom="12dip" android:layout_marginRight="12dip" android:layout_marginTop="12dip" android:maxHeight="296dip" android:maxWidth="296dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:width="296dip" android:height="296dip" android:layout_marginLeft="-10dip" android:textSize="24dip"></Button> </FrameLayout>
上面主vxml
下面是地球的正反旋转
<?xml version="1.0" encoding="UTF-8"?> <!-- Animation frames for earth --> <!-- android:id="@+id/earth_animation" --> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" android:visible="true"> <item android:drawable="@drawable/earth0" android:duration="150" /> <item android:drawable="@drawable/earth1" android:duration="150" /> <item android:drawable="@drawable/earth2" android:duration="150" /> <item android:drawable="@drawable/earth3" android:duration="150" /> <item android:drawable="@drawable/earth4" android:duration="150" /> <item android:drawable="@drawable/earth5" android:duration="150" /> <item android:drawable="@drawable/earth6" android:duration="150" /> <item android:drawable="@drawable/earth7" android:duration="150" /> <item android:drawable="@drawable/earth8" android:duration="150" /> <item android:drawable="@drawable/earth9" android:duration="150" /> </animation-list>
<?xml version="1.0" encoding="UTF-8"?> <!-- Animation frames for earth --> <!-- android:id="@+id/earth_animation_rev" --> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" android:visible="true"> <item android:drawable="@drawable/earth9" android:duration="150" /> <item android:drawable="@drawable/earth8" android:duration="150" /> <item android:drawable="@drawable/earth7" android:duration="150" /> <item android:drawable="@drawable/earth6" android:duration="150" /> <item android:drawable="@drawable/earth5" android:duration="150" /> <item android:drawable="@drawable/earth4" android:duration="150" /> <item android:drawable="@drawable/earth3" android:duration="150" /> <item android:drawable="@drawable/earth2" android:duration="150" /> <item android:drawable="@drawable/earth1" android:duration="150" /> <item android:drawable="@drawable/earth0" android:duration="150" /> </animation-list>
1 楼
blackspot_zero
2012-02-03
mark
最新技术文章: