这是我的代码,我正在尝试打开图库..我收到错误,如上所述
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import java.io.ByteArrayOutputStream;
public class ChangeUserImageActivity extends Activity {
private static final int SELECT_PICTURE = 1;
private static final int CAMERA_PIC_REQUEST = 1337;
private Bitmap thumbnail = null;
String img = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.changeuserimage);
}
public void camera_click(View view) {
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
public void gallery_click(View v) {
// select …Run Code Online (Sandbox Code Playgroud) 我之后调用setContentView()时收到此错误
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.maintitlebar);
Run Code Online (Sandbox Code Playgroud)
代码在我的类的onCreate()中,它扩展了ListActivity.我的清单XML文件显示了应用程序的默认AppTheme:
android:theme="@style/AppTheme"
Run Code Online (Sandbox Code Playgroud)
我已将styles.xml更新为:
<resources>
<style name="AppTheme" parent="android:Theme.Light" >
<item name="android:windowNoTitle">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这似乎与此错误消息的主要帖子一致.我还清理了构建,但我仍然收到上述错误消息.有谁知道造成冲突的原因是什么?
在清单文件中,我将此行添加到我的应用程序标记中
android:theme="@android:style/Theme.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
基本上每个活动都没有标题栏,但是对于我希望显示标题栏的其中一个活动
我知道要隐藏栏我可以使用此代码
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
如何从代码中显示标题栏?
编辑 请不要高我怎么能隐藏标题栏:),我知道,如果有人知道我怎么能显示它?
我知道我可以把NoTitleBar放在我想要隐藏的每个活动中,我可以把它留给我想要展示的那个......但那不是我的观点
android titlebar android-titlebar android-theme android-activity
是否可以在应用标题的右上角添加一个按钮?
例如,在"Feed:my feeds"的标题中添加"刷新"按钮?
http://www.android.com/market/apps/feedr-lg-01.jpg alt text http://www.android.com/market/apps/feedr-lg-01.jpg
在我的onCreate()中,我设置了一个进度条,如下所示:
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
Run Code Online (Sandbox Code Playgroud)
现在,希望稍微增强标题栏,我想改变它的背景颜色.第一步是检查是否FEATURE_CUSTOM_TITLE支持:
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if ( customTitleSupported ) {
Log.i(TAG, "CUSTOM TITLE SUPPORTED!")
}
Run Code Online (Sandbox Code Playgroud)
但是一旦我打电话给requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)我得到一个:
AndroidRuntimeException: You cannot combine custom titles with other title features
Run Code Online (Sandbox Code Playgroud)
(如果我在设置之前FEATURE_PROGRESS或之后调用此函数无关紧要)
知道如何解决这个问题吗?
或者,如果我能找到非自定义标题栏的资源ID,我会避免使用自定义标题栏.比危险的getParent()更好的东西.
这可能吗?
我似乎无法通过这个错误:
android.util.AndroidRuntimeException:您无法将自定义标题与其他标题功能组合在一起
我正在运行API> 14.
清单如下:
<activity
android:name=".activity.ActivityWelcome"
android:label="@string/app_label_name"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:theme="@style/My.Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我的活动是做以下事情:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.welcome);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_main);
...
Run Code Online (Sandbox Code Playgroud)
在哪里R.layout.window_title_main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_title"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="5dp" >
<TextView
android:id="@+id/textview_title"
android:drawableLeft="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="-1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当它似乎适合其他人时,为什么这不起作用?