我想在图像的底部添加渐变.像这样的东西:
我试过这样的东西,但我只得到渐变没有图像..
<ImageView
android:id="@+id/trendingImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/trend_donald_sterling"
android:src="@drawable/trending_gradient_shape"
/>
Run Code Online (Sandbox Code Playgroud)
trending_gradient_shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="@android:color/darker_gray"
android:startColor="@android:color/darker_gray" />
<corners android:radius="0dp" />
</shape>
Run Code Online (Sandbox Code Playgroud) 当电话铃响时,我设法准备了一项活动.现在我需要知道如何取消这个活动,当我打电话或拒绝电话时.我是否打电话给EXTRA_STATE_IDLE?EXTRA_STATE_OFFHOOK?
有任何想法吗?
<receiver android:name=".IncomingBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
public class IncomingBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
// If an incoming call arrives
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{ //Did my work }
Run Code Online (Sandbox Code Playgroud) 我正在尝试按顺序运行toast以显示ruuning rss feed.运行时出现以下错误:java.lang.RuntimeException:此Toast未使用Toast.makeText()创建
我的代码是:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
ImageView image = (ImageView) layout.findViewById(R.id.toastimage);
image.setImageResource(R.drawable.bball_icon);
TextView text = (TextView) layout.findViewById(R.id.toasttext);
Toast toast = new Toast(getApplicationContext());
toast.setView(layout);
for (int i=0;i<episode_titles.size();i++)
{
toast.setText(episode_titles.get(i).toString());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
}
Run Code Online (Sandbox Code Playgroud) 我无法找到调用Intent屏幕"选择屏幕锁定"的任何参考.
找不到任何东西?
任何的想法?
我正在尝试在启动拨出呼叫后识别并转移到活动.我ACTION_NEW_OUTGOING_CALL
在Intent过滤器中使用过.但是我怎么认识到呼叫是外向的.我为来电做了这个(如下所示),但我可以用什么而不是EXTRA_STATE_RINGING
.
public class OutgoingBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{
Intent i = new Intent(context, OutgoingCallScreenDisplay.class);
i.putExtras(intent);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想每24小时向我的服务器发送一下我走了几步.我有一个AlarmManager即可关闭alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),1000*60*60*24, pendingIntent1)
现在这就是我被困住的地方......我应该如何衡量每日步骤?(记住我需要在后台发送这个)我可以使用这个可以覆盖此功能的服务,public void onSensorChanged(SensorEvent event)
这似乎不太准确,因为我的服务可以被摧毁(电池会很快耗尽).
要么
我可以尝试使用Google Fitness,但每次尝试获取数据时mGoogleApiClient.connect()
我都需要用户请求连接(我需要在后台获取此数据)
有没有经验呢?
我想扩大我的按钮高度.我试图给行充气,但它没有任何想法?
查看我的更新代码与相对布局和tablelayot ...
尝试扩大行和tablelayout相同的结果......
我试过enl XML
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/black_bg"
android:layout_centerVertical="true">
<TableLayout android:id="@+id/row1"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:paddingRight="5px"
android:paddingLeft="5px"
android:paddingTop="15px"
android:paddingBottom="5px"
android:layout_weight="1">
<TableRow
android:layout_weight="1"
android:layout_height="50dip">
<ToggleButton android:id="@+id/btn_service_plus"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:textSize="12dip"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="1"
android:layout_weight="1"
/>
<Button
android:layout_marginLeft="4px"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
/>
<Button
android:layout_marginLeft="4px"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
/>
<ToggleButton
android:layout_marginLeft="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
android:background="@drawable/menu_button_layout"/>
</TableRow>
Run Code Online (Sandbox Code Playgroud) 我有一个通知,当我选择时,它会发送Broadcast
一个BroadcastReceiver
使用a PendingIntent
.在onReceive
我开始新的Activity
.
但是,如果我从最近打开的应用程序中移除我的应用程序(或通知在绘图中长时间停留),则会出现以下情况:
当我在抽屉里有多个通知时,第一个通知很好.在点击第二个之后,我onCreate()
和我onResume()
的被叫,它就好像startActivity()
根本不工作一样.如果我添加标志Intent.FLAG_ACTIVITY_SINGLE_TOP
然后onNewIntent
被调用.
notificationIntent = new Intent();
notificationIntent.setAction(AppConstants.ACTION_ACTIVITY);
notificationIntent.putExtra("key", value);
int requestID = (int) System.currentTimeMillis();
mBuilder.setContentIntent(PendingIntent
.getBroadcast(context, requestID, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT));
Run Code Online (Sandbox Code Playgroud)
的onReceive
Intent intent = new Intent(context, Activity.class);
intent.putExtra("key", value);
//IF I ADD FLAG_ACTIVITY_SINGLE_TOP IT WORKS
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud) android android-notifications android-activity android-broadcast
我目前正在拦截一个电话并将其转发到我自定义的"oncallscreen"活动.但是,在进入我的屏幕之前,它将闪烁到默认的"oncallscreen".如何隐藏/取消此屏幕,以便在接听电话时我只获得自定义屏幕.
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
String state = extras.getString(TelephonyManager.EXTRA_STATE);
Log.w("DEBUG", state);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String phoneNumber = extras
.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Run Code Online (Sandbox Code Playgroud) 我正在使用 YouTube API 在我的应用中播放视频。
我想在用户输入片段时立即播放视频,所以我使用命令player.play();
来自动播放。但是这个命令似乎不起作用......
这是我的代码:
public class YouTubeVideoFragment extends YouTubePlayerFragment{
YouTubePlayer player;
public YouTubeVideoFragment()
{
}
@Override
public void onDestroy()
{
// TODO Auto-generated method stub
super.onDestroy();
if(player!= null)
{
player.release();
}
}
@Override
public void onStop()
{
// TODO Auto-generated method stub
super.onStop();
if(player!= null)
{
player.release();
}
}
public static YouTubeVideoFragment newInstance(String url)
{
YouTubeVideoFragment f = new YouTubeVideoFragment();
Bundle b = new Bundle();
b.putString("url", url);
f.setArguments(b);
f.init();
return f;
}
private void init()
{ …
Run Code Online (Sandbox Code Playgroud)