我搜索了很多但找不到方法,如何在ActionBar的中心设置标题,而不是左对齐.我使用下面的代码将标题设置在中心:
ViewGroup decorView= (ViewGroup) this.getWindow().getDecorView();
LinearLayout root= (LinearLayout) decorView.getChildAt(0);
FrameLayout titleContainer= (FrameLayout) root.getChildAt(0);
TextView title= (TextView) titleContainer.getChildAt(0);
title.setGravity(Gravity.CENTER);
Run Code Online (Sandbox Code Playgroud)
但它给出了如下错误:
ClassCastException : com.android.internal.widget.ActionBarView can not
be cast to android.widget.TextView.
Run Code Online (Sandbox Code Playgroud)
任何其他解决方案..任何帮助将不胜感激.
我想将一个Button添加到Action栏的右侧,如此屏幕截图所示:

我在onCreate方法中获取actionBar:
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
Run Code Online (Sandbox Code Playgroud)
和后退按钮(onOptionsItemSelected方法)如下:
public boolean onOptionsItemSelected(MenuItem item){
Intent myIntent = new Intent(getApplicationContext(),MainActivity.class);
startActivityForResult(myIntent, 0);
return true;
}
Run Code Online (Sandbox Code Playgroud)
我该如何添加按钮?
在我的Android应用程序中,我试图从GoogleAuthUtil获取AccessToken,如下所示:
accessToken = GoogleAuthUtil.getToken(this,mPlusClient.getAccountName(),"oauth2:"+ SCOPES);
但在这一行我得到的错误如下:
E/GoogleAuthUtil(4696):调用此从你的主线程可以导致死锁和/或ANR的E/GoogleAuthUtil(4696):java.lang.IllegalStateException:调用该从你的主线程可以导致死锁E/GoogleAuthUtil(4696) :在com.google.android.gms.auth.GoogleAuthUtil.b(未知来源)E/GoogleAuthUtil(4696):在com.google.android.gms.auth.GoogleAuthUtil.getToken(未知来源)E/GoogleAuthUtil(4696) :at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
任何这个问题的解决方案?任何帮助将不胜感激.
我在Android App中集成了Google Plus.我使用的是Android SDK版本4.2.2.但是我在google plus上执行共享帖时遇到了这个错误:
Google Plus服务已过期
和
ConnectionResult {statusCode = SERVICE_VERSION_UPDATE_REQUIRED,resolution = null}
我想在模拟器上运行Google Plus发布,而不是在设备上运行.
任何帮助将不胜感激.
在Android应用程序中,
在一项活动中,我可以使用google plus登录,如下所述:https: //developers.google.com/+/mobile/android/sign-in
但我想从谷歌加上从不同的活动登出.所以,当我点击退出按钮然后我正在执行此代码...但是这里isConnected()方法总是返回false,因为用户不再连接..那么我如何使用AccessToken连接用户我从第一个活动存储?
if (mPlusClient.isConnected()) {
mPlusClient.clearDefaultAccount();
mPlusClient.disconnect();
Log.d(TAG, "User is disconnected.");
}
Run Code Online (Sandbox Code Playgroud)
那么我如何使用访问令牌从不同的活动中注销用户?
任何帮助将不胜感激.
在我的Android应用程序中,
我使用默认主题Theme.Holo.Light.
现在我想要使用以下命令更改默认的"<"符号:
<item name="homeAsUpIndicator">@android:drawable/ic_ab_back_holo_light</item>
Run Code Online (Sandbox Code Playgroud)
通过将此更改为
<item name="homeAsUpIndicator">@drawable/ic_launcher</item>
Run Code Online (Sandbox Code Playgroud)
但这里的标志仍然存在,它不会改变图像.我附上了actionBar的屏幕截图.任何帮助将不胜感激.

我exec在PHP中使用如下命令:
exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");
Run Code Online (Sandbox Code Playgroud)
在我的本地环境(毫安),我知道PHP的安装路径,这样我就可以代替/usr/bin/php使用/Applications/MAMP/bin/php/php5.4.10/bin/php.但我不知道PHP安装(PHP二进制文件)在生产服务器上的位置.
php binary installation production-environment installation-path
在我的Android应用程序中,我在地球上有三个不规则形状,如下所示:

所以我将整个图像放在布局中.Globe is just an image .There is no role of globe here.现在我想在全球各个不规则形状的图像上放置一个按钮.
按钮总是长方形但是I want to get touch event for irregular shape,not for rectangular area.那么如何在这三个不规则形状上放三个按钮或者有任何解决方案?这样每个按钮的不同事件可以在活动中处理?
我不知道如何完成这项任务.请指导我这个.
有什么建议或意见吗?
任何帮助将不胜感激.
在iOS应用程序中,我目前针对男性和女性的UISegmented Control看起来像这样:

现在我想更改这些段的背景图像.所以我在故事板中更改如下:
For Segment 0:
Run Code Online (Sandbox Code Playgroud)

For Segment 1:
Run Code Online (Sandbox Code Playgroud)

After this changes,I got the result as below :
Run Code Online (Sandbox Code Playgroud)

为什么这些图像相互重叠?任何具体原因或这些细分大小是根据图像大小?如何在不影响段大小的情况下设置段的背景图像(完整图像应显示在段的背景中而不是重叠)?
任何帮助将不胜感激.
我有一个文件,Notification.php这是一个类.它的结构是这样的:
Class Notificaiton
{
public function sendNotification($token,$count)
{
// Here is the code for sending push notification(APNS)
}
}
Run Code Online (Sandbox Code Playgroud)
通常,如果我想从另一个PHP文件中调用此函数,那么我必须创建一个类的对象,然后调用它的方法如下:
$notification = new Notification();
$notification->sendNotification($token,$value);
Run Code Online (Sandbox Code Playgroud)
但我想做的是在后台进程中调用它.所以我使用exec()如下命令:
exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");
Run Code Online (Sandbox Code Playgroud)
在这里,我不知道如何可以调用function(sendNotificaiton())的file(Notification.php),并传递参数的参数:$令牌和$算什么?
我发现exec/shell_exec/passthru commands可以帮助我.但在这种情况下,我用这三个命令中的哪个命令?
请指导我这个.任何帮助将不胜感激.