当前位置: 编程技术>移动开发
本页文章导读:
▪TextView中各种Interpolator的施用 TextView中各种Interpolator的使用
Java代码 package net.blogjava.mobile.interpolators; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import andr.........
▪ Looper物品之角色(Demo 4) Looper物件之角色(Demo 4)
这个例子主要演示了主,子线程之间的信息交互 Java代码 package com.example.Looper_04; import android.app.Activity; import android.content.Context; import android.graphics.Color; .........
▪ idp证书怎么给另一台机子使用 idp证书如何给另一台机子使用
1. 现在主机子上用Xcode->Windows->Organizer, 在DEVELOPMENT下点击Developer profile, 在其右边点击Expore Develper profile按钮, 再弹出的对话框中输入保存的文件名,密码.
2..........
[1]TextView中各种Interpolator的施用
来源: 互联网 发布时间: 2014-02-18
TextView中各种Interpolator的使用
Java代码
package net.blogjava.mobile.interpolators;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class Main extends Activity implements
AdapterView.OnItemSelectedListener {
private static final String[] INTERPOLATORS = { "Accelerate", "Decelerate",
"Accelerate/Decelerate", "Anticipate", "Overshoot",
"Anticipate/Overshoot", "Bounce" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, INTERPOLATORS);
adapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView parent, View v, int position, long id) {
final View target = findViewById(R.id.target);
final View targetParent = (View) target.getParent();
Animation animation = new TranslateAnimation(0.0f, targetParent
.getWidth()
- target.getWidth()
- targetParent.getPaddingLeft()
- targetParent.getPaddingRight(), 0.0f, 0.0f);
animation.setDuration(1000);
animation.setStartOffset(300);
animation.setRepeatMode(Animation.RESTART);
animation.setRepeatCount(Animation.INFINITE);
switch (position) {
case 0:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.accelerate_interpolator));
break;
case 1:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.decelerate_interpolator));
break;
case 2:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.accelerate_decelerate_interpolator));
break;
case 3:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.anticipate_interpolator));
break;
case 4:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.overshoot_interpolator));
break;
case 5:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.anticipate_overshoot_interpolator));
break;
case 6:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.bounce_interpolator));
break;
}
target.startAnimation(animation);
}
public void onNothingSelected(AdapterView parent) {
}
}
Java代码
package net.blogjava.mobile.interpolators;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class Main extends Activity implements
AdapterView.OnItemSelectedListener {
private static final String[] INTERPOLATORS = { "Accelerate", "Decelerate",
"Accelerate/Decelerate", "Anticipate", "Overshoot",
"Anticipate/Overshoot", "Bounce" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, INTERPOLATORS);
adapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(this);
}
public void onItemSelected(AdapterView parent, View v, int position, long id) {
final View target = findViewById(R.id.target);
final View targetParent = (View) target.getParent();
Animation animation = new TranslateAnimation(0.0f, targetParent
.getWidth()
- target.getWidth()
- targetParent.getPaddingLeft()
- targetParent.getPaddingRight(), 0.0f, 0.0f);
animation.setDuration(1000);
animation.setStartOffset(300);
animation.setRepeatMode(Animation.RESTART);
animation.setRepeatCount(Animation.INFINITE);
switch (position) {
case 0:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.accelerate_interpolator));
break;
case 1:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.decelerate_interpolator));
break;
case 2:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.accelerate_decelerate_interpolator));
break;
case 3:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.anticipate_interpolator));
break;
case 4:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.overshoot_interpolator));
break;
case 5:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.anticipate_overshoot_interpolator));
break;
case 6:
animation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.bounce_interpolator));
break;
}
target.startAnimation(animation);
}
public void onNothingSelected(AdapterView parent) {
}
}
[2] Looper物品之角色(Demo 4)
来源: 互联网 发布时间: 2014-02-18
Looper物件之角色(Demo 4)
这个例子主要演示了主,子线程之间的信息交互
Java代码
package com.example.Looper_04;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Looper_04 extends Activity implements OnClickListener {
private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
private final int FP = LinearLayout.LayoutParams.FILL_PARENT;
public TextView tv;
private myThread t;
private Button btn, btn2;
private Handler h;
private Context ctx;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
ctx = this;
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
btn = new Button(this);
btn.setId(101);
btn.setBackgroundResource(R.drawable.icon);
btn.setText("test looper");
btn.setOnClickListener(this);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(100, 50);
param.topMargin = 10;
layout.addView(btn, param);
btn2 = new Button(this);
btn2.setId(102);
btn2.setBackgroundResource(R.drawable.icon);
btn2.setText("exit");
btn2.setOnClickListener(this);
layout.addView(btn2, param);
tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setText("");
LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(FP, WC);
param2.topMargin = 10;
layout.addView(tv, param2);
setContentView(layout);
// 这里执行了子线程
t = new myThread();
t.start();
}
public void onClick(View v) {
switch (v.getId()) {
case 101:
String obj = "mainThread";
Message m = h.obtainMessage(1, 1, 1, obj);
// 发送的消息由子线程的handler来进行处理
h.sendMessage(m);
break;
case 102:
h.getLooper().quit();
finish();
break;
}
}
// ------------------------------------------------
public class EventHandler extends Handler {
public EventHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
((Activity) ctx).setTitle((String) msg.obj);
}
}
// ------------------------------------------------
class myThread extends Thread {
public void run() {
// 初始化当前子线程的Looper物件之管理对象
Looper.prepare();
h = new Handler() {
public void handleMessage(Message msg) {
//又建立了主线程的handler对象
EventHandler ha = new EventHandler(Looper.getMainLooper());
String obj = (String) msg.obj + ", myThread";
Message m = ha.obtainMessage(1, 1, 1, obj);
ha.sendMessage(m);
}
};
Looper.loop();
}
}
}
这个例子主要演示了主,子线程之间的信息交互
Java代码
package com.example.Looper_04;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Looper_04 extends Activity implements OnClickListener {
private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
private final int FP = LinearLayout.LayoutParams.FILL_PARENT;
public TextView tv;
private myThread t;
private Button btn, btn2;
private Handler h;
private Context ctx;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
ctx = this;
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
btn = new Button(this);
btn.setId(101);
btn.setBackgroundResource(R.drawable.icon);
btn.setText("test looper");
btn.setOnClickListener(this);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(100, 50);
param.topMargin = 10;
layout.addView(btn, param);
btn2 = new Button(this);
btn2.setId(102);
btn2.setBackgroundResource(R.drawable.icon);
btn2.setText("exit");
btn2.setOnClickListener(this);
layout.addView(btn2, param);
tv = new TextView(this);
tv.setTextColor(Color.WHITE);
tv.setText("");
LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(FP, WC);
param2.topMargin = 10;
layout.addView(tv, param2);
setContentView(layout);
// 这里执行了子线程
t = new myThread();
t.start();
}
public void onClick(View v) {
switch (v.getId()) {
case 101:
String obj = "mainThread";
Message m = h.obtainMessage(1, 1, 1, obj);
// 发送的消息由子线程的handler来进行处理
h.sendMessage(m);
break;
case 102:
h.getLooper().quit();
finish();
break;
}
}
// ------------------------------------------------
public class EventHandler extends Handler {
public EventHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
((Activity) ctx).setTitle((String) msg.obj);
}
}
// ------------------------------------------------
class myThread extends Thread {
public void run() {
// 初始化当前子线程的Looper物件之管理对象
Looper.prepare();
h = new Handler() {
public void handleMessage(Message msg) {
//又建立了主线程的handler对象
EventHandler ha = new EventHandler(Looper.getMainLooper());
String obj = (String) msg.obj + ", myThread";
Message m = ha.obtainMessage(1, 1, 1, obj);
ha.sendMessage(m);
}
};
Looper.loop();
}
}
}
[3] idp证书怎么给另一台机子使用
来源: 互联网 发布时间: 2014-02-18
idp证书如何给另一台机子使用
1. 现在主机子上用Xcode->Windows->Organizer, 在DEVELOPMENT下点击Developer profile, 在其右边点击Expore Develper profile按钮, 再弹出的对话框中输入保存的文件名,密码.
2.将主机上导出的.develperprofile文件拷贝到另一台机子上, 在这台机子上也用Xcode->Windows->Organizer, 在DEVELOPMENT下点击Developer profile, 在其右边点击Import Develper profile按钮, 将这个.develpoerprofile导入,密码就是第一个步骤里设定的密码.
最新技术文章: