当我进入下一个活动时,我能够给出自下而上的动画,但现在当我按下时,我使用相同的代码从上到下动画制作动画,但它总是自下而上,所以我的问题是如何给动画我在Android设备上按下按钮时从上到下?
请在下面找到我的代码.
我使用它在从一个过渡Activity到另一个过程中使用它Intent.
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
Run Code Online (Sandbox Code Playgroud)
和xml是:slide_in_up.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime"/>
Run Code Online (Sandbox Code Playgroud)
和slide_out_up.xml是
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="-100%p"
android:duration="@android:integer/config_longAnimTime"/>
Run Code Online (Sandbox Code Playgroud) 是否可以将EditText框内的字符串文本转换为位图?换句话说,有没有办法将字符串文本转换为位图,这意味着文本将显示为图像?
以下是我的代码:
class TextToImage extends Activity {
protected void onCreate(Bundle savedInstanceState) {
//create String object to be converted to image
String sampleText = "SAMPLE TEXT";
String fileName = "Image";
//create a File Object
File newFile = new File("./" + fileName + ".jpeg");
//create the font you wish to use
Font font = new Font("Tahoma", Font.PLAIN, 11);
//create the FontRenderContext object which helps us to measure the text
FontRenderContext frc = new FontRenderContext(null, true, true);
}
}
Run Code Online (Sandbox Code Playgroud) 我想为文本视图执行捏合功能(放大/缩小).
我已经参考了很多教程,但没有得到任何有成效的...请帮助我,如果有人做过或知道如何做到....
使用按钮作为放大和/或使用2指针捏还可以吗?
任何帮助将不胜感激..谢谢
不工作的代码:
setContentView(R.layout.main);
mainView =(LinearLayout)findViewById(R.id.linearLayout);
Button buttonZoomOut = (Button)findViewById(R.id.buttonZoomOut);
Button buttonNormal = (Button)findViewById(R.id.buttonNormal);
Button buttonZoomIn = (Button)findViewById(R.id.buttonZoomIn);
buttonZoomOut.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoom(0.5f,0.5f,new PointF(0,0));
}
});
buttonNormal.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
zoom(1f,1f,new PointF(0,0));
}
});
buttonZoomIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoom(2f,2f,new PointF(0,0));
}
});
}
/** zooming is done from here */
public void zoom(Float scaleX,Float scaleY,PointF pivot){
mainView.setPivotX(pivot.x);
mainView.setPivotY(pivot.y);
mainView.setScaleX(scaleX);
mainView.setScaleY(scaleY);
}
Run Code Online (Sandbox Code Playgroud) 我有一个ListView,内容如第一行假设android,第二行黑莓和第三行iphone所以现在我想让ListView的整行可点击但是当我点击listview行的上面的内容时它只执行点击事件但是我如果我点击连续的任何位置然后应该执行点击操作.我可以使用以下列表查看listview clickable的代码如下:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.listartistspacedetailview);
setListAdapter(new ArrayAdapter(this,R.layout.listitem_layout,R.id.barrio, keywordxmlparsing.array_artistname));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long thisID)
{
Intent i = new Intent(Artistspacedetailview.this, Loadingimagetab.class);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
和xml文件中的ListView标记是:
<ListView
android:clickable="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_below="@id/horizontolline"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="false" />
Run Code Online (Sandbox Code Playgroud) 我想关闭或停止运行应用程序当我退出主屏幕意味着当我在android中按回按钮时应用程序的第一个布局.我用这个,但我的应用程序是在后台运行
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Splash screen view
setContentView(R.layout.splash);
}
**public void onDestroy()
{
super.onDestroy();
System.runFinalizersOnExit(true);
System.exit(0);
}**
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序运行时每隔5分钟制作一个火警管理器的服务.那怎么办?
Intent intent = new Intent(this, OnetimeAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), sender);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
Run Code Online (Sandbox Code Playgroud) 我正在安排任务并根据日期和时间添加警报管理器,并且计划任务正在添加到列表中..当我添加任何任务时,它还在sqlite数据库中添加并为警报管理器分配pendinng意图的唯一ID.
现在,如果我想取消警报,那么如果我从列表中删除该行,那么我也想解除该特定警报..我能够从数据库中删除行但是如何解除该行的警报集?
我的代码如下:
Button AddData=(Button)findViewById(R.id.senddata);
AddData.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);
Date= updatedate.getText().toString();
Time= updateTime.getText().toString();
Discripton= discription.getText().toString();
//---get current date and time---
Calendar calendar = Calendar.getInstance();
//---sets the time for the alarm to trigger---
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, mHour);
calendar.set(Calendar.MINUTE, mMinute);
calendar.set(Calendar.SECOND, 0);
Log.i("********####",year+" ,"+month+" , "+day+" , "+mHour+" , "+mMinute+"----"+ calendar.getTimeInMillis());
Intent intent = new Intent(AddEditExpense.this, TimeAlarm.class);
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Bundle b12 …Run Code Online (Sandbox Code Playgroud) 当我点击软键盘我的键盘下降或隐藏但我想进入下一个活动当我点击android.so键盘上的"完成"按钮怎么办?
我的下一个问题是如果我在我的布局中有2个编辑框,当我点击第一个编辑框然后在我的软键盘中"下一个"将出现进入下一个文本框,当我转到第二个文本框时它变为"完成".提前致谢....
X
朋友们,我无法将广播从一个活动发送到其他活动请参阅下面的代码并提供帮助:
public class SendBroadcast extends Activity {
public static String BROADCAST_ACTION = "com.unitedcoders.android.broadcasttest.SHOWTOAST";
/* }
});
}
public void sendBroadcast(){
Intent broadcast = new Intent("com.unitedcoders.android.broadcasttest.SHOWTOAST");
this.sendBroadcast(broadcast);
//startActivity(broadcast);
}
Run Code Online (Sandbox Code Playgroud)
}
接收方代码:
public class ToastDisplay extends Activity {
private BroadcastReceiver mReceiver;
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
Log.i("!!!!!!!InchooTutorial@@@@@@@$$$$","%%%%%%% msg_for_me");
Run Code Online (Sandbox Code Playgroud)
ent // String msg_for_me = intent.getStringExtra("some_msg"); //记录我们的消息值Log.i("!!!!!!! InchooTutorial @@@@@@ $$$$","%%%%%%% msg_for_me");
}
};
//registering our receiver
this.registerReceiver(mReceiver, intentFilter);
}
@Override
protected void onPause() {
// TODO Auto-generated method …Run Code Online (Sandbox Code Playgroud) 有人可以帮我理解" 未决意图 "吗?一些例子也会有所帮助.
我用Google搜索并发现了一些信息,但我仍然无法理解它.
NotificationManager notificationManager;
PendingIntent pendingIntent;
Updater() {
notificationManager = (NotificationManager) UpdaterService.this
.getSystemService(Context.NOTIFICATION_SERVICE);
notification = new Notification( android.R.drawable.stat_sys_download,
"MyTwitter", System.currentTimeMillis());
pendingIntent = PendingIntent.getActivity(UpdaterService.this, 0,
new Intent(UpdaterService.this, Timeline.class), 0);
}
Run Code Online (Sandbox Code Playgroud) 我在android中使用进度条,但是在钛中它的活动指示器用于显示某些进展在android的背景上我通过制作异步任务但是在钛我应该编写用于处理背景任务的代码,意味着直到我的后台任务没有完成daisply指示器并在完成后自动隐藏...我的代码为activty indiator和我想在后台显示它的任务在下面..
var ind = Titanium.UI.createActivityIndicator({
location:Titanium.UI.ActivityIndicator.DIALOG,
//type:Titanium.UI.ActivityIndicator.DETERMINANT,
width:50,
height:50,
message: 'loading...',
color: 'FF0000'
});
curWin.add(ind);
ind.show();
and want to put below code which will be run on back ground.....
var image = imgvwPlus.image;
var filename = new Date().getTime() + "-ea.jpg";
bgImage = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory,filename);
// Write the image to the new file (image created from camera)
bgImage.write(image);
imageArray.length = imageArray.length + 1;
//alert(bgImage);
custom[j]={"hanger":btntext[0].title,
"color": btntext[1].title,
"size": btntext[2].title,
"text": btntext[3].title,
"textStyle": btntext[3].font.fontFamily,
"textSize": btntext[3].font.fontSize,
"textColor": btntext[3].color,
"textTop":textTop,
"textLeft":textLeft,
"quantity":quantity,
"price":price …Run Code Online (Sandbox Code Playgroud) 我想让我的视图可滚动,我的视图包含线性布局内的子视图布局.
我的代码如下; 请使其可滚动,以便显示每个内容...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#1A77BD">
<RelativeLayout
android:layout_marginTop="15dip"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF">
<TextView
android:layout_marginTop="3dip"
android:id="@+id/version"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TYPE"
android:layout_marginLeft="5dip"
android:textColor="#000000" />
<Spinner
android:id="@+id/spinner1"
android:layout_marginTop="0dip"
android:layout_marginLeft="100dip"
android:layout_height="40dip"
android:layout_width="200dip" />
<TextView
android:id="@+id/update_me"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="DATE"
android:layout_marginTop="80dip"
android:layout_marginLeft="5dip"
android:textColor="#000000" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
android:background="#FFFFFF">
<TextView
android:id="@+id/accsetting"
android:layout_marginLeft="5dip"
android:layout_marginTop="2dip"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COUNTRY" />
<Spinner
android:id="@+id/spinner3"
android:layout_marginTop="0dip"
android:layout_marginLeft="100dip"
android:layout_height="40dip"
android:layout_width="200dip" />
<TextView
android:layout_marginLeft="5dip"
android:layout_marginTop="52dip"
android:textColor="#000000"
android:id="@+id/savecorp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STATE" /> …Run Code Online (Sandbox Code Playgroud)