我想在EditText(在TextInputLayout中)中使用java设置提示.
用于设置提示的代码:
aET = (EditText) findViewById(R.id.aET);
aET.setHint("h?");
但即使关注edittext,Hint也会显示两次(也在edittext内).
如果有人面对并找到一些解决方法,请告诉我
当editText聚焦时......

当editText没有聚焦时..

编辑[2015年7月10日]:
<android.support.design.widget.TextInputLayout
android:id="@+id/aTIL"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/aET" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) android android-appcompat android-edittext android-textinputlayout
我在我的应用程序中使用AppCompat库(com.android.support:appcompat-v7:22.1.0).我在一个片段中创建了一个ActionBar.当我单击菜单项时,它会显示一个警告对话框.这是我的代码:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_new:
showFilterDialog();
return true;
case R.id.action_send:
new sendInventoryTask().execute();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
和我的showInventoryDialog方法:
private void showFilterInventoryDialog() {
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
LayoutInflater inflater= getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.dialog_filter_inventory,null);
alert.setView(v);
alert.setTitle(getResources().getString(R.string.filters));
alert.setPositiveButton(getResources().getString(R.string.filter), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// TODO
}
});
alert.setNegativeButton(getResources().getString(R.string.cancel), null);
alert.show();
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但当我点击菜单项时,logcat显示错误:
I/AppCompatDelegate:Activity的LayoutInflater已安装了Factory,因此我们无法安装AppCompat的
怎么解决这个?
使用AppCompat工具栏,我希望能够在ActionMode更改时更改溢出菜单图标的颜色.
例如,在正常工具栏模式下,溢出图标将为白色.并且会在ActionMode上变黑.到目前为止,我已经设法改变了动作模式的背景以及标题文本.但我还没有找到一种方法来改变溢出菜单图标的颜色.
我知道有一个答案: 更改ActionMode Overflow图标
我尝试了第一个解决方案,但我无法找到溢出图标.
第二种解决方案,即使延迟50L,也会导致溢出菜单图标闪烁ActionMode的预期颜色,短时间内非常刺耳.
上下文
我正在使用最新的AppCompat v7 lib(21.0.0),我已将我的应用程序从ActionBar迁移到ToolBar
问题
目前SearchBox是在操作栏上设置的自定义视图(来自之前的实现)我计划切换到SearchView并相应地设置它,但我仍然对我现在面临的问题非常感兴趣.


我怎么能避免这个?
这是我的工具栏布局以及样式和主题
layout v_toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/MyActionBarStyle"/>
Run Code Online (Sandbox Code Playgroud)
价值观/ styles.xml
<style name="MyActionBarStyle" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">@color/green</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="background">@color/green</item>
<item name="windowActionBarOverlay">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
主题
<style name="MyTheme" parent="AppBaseTheme">
<!-- Here we setting appcompat’s actionBarStyle -->
<!-- <item name="actionBarStyle">@style/MyActionBarStyle</item> -->
<item name="windowActionBar">false</item>
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green_dark</item>
</style>
Run Code Online (Sandbox Code Playgroud)
问题1的解决方法1
第一个问题的解决方法是在ImageView上设置透明背景
android:background="@color/transparent"
Run Code Online (Sandbox Code Playgroud)
这并不能解决问题.
解决这两个问题
我为ToolBar设置了一个背景 …
我正在使用AppCompat编写一个材质设计风格的应用程序.由于AppCompat不会影响对话框,因此我将对对话框进行外观设置:
styles.xml:
<style name="AppTheme.Base" parent="Theme.AppCompat">
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green_darker</item>
<item name="colorAccent">@color/accent</item>
<item name="android:alertDialogTheme">@style/alertDialog</item>
<item name="android:dialogTheme">@style/alertDialog</item>
</style>
<style name="alertDialog" parent="Theme.AppCompat.Dialog">
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green_darker</item>
<item name="colorAccent">@color/accent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我在android api> = 21时得到了我想要的东西,但在其他设备上我最终在对话框周围有一个"框".
有没有办法摆脱对话框周围的"盒子",甚至在api <21上应用颜色和材质主题,最好没有任何额外的依赖?
App <Api <21:

API> = 21上的应用:

android android-appcompat android-support-library material-design
我正在尝试使用AppCompatActivity和support.v7.preference在子屏幕上实现首选项
根据文档,另一个PreferenceScreen中的每个PreferenceScreen都用作子屏幕,框架将处理单击时显示它. http://developer.android.com/guide/topics/ui/settings.html#Subscreens
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- opens a subscreen of settings -->
<PreferenceScreen
android:key="button_voicemail_category_key"
android:title="@string/voicemail"
android:persistent="false">
<ListPreference
android:key="button_voicemail_provider_key"
android:title="@string/voicemail_provider" ... />
<!-- opens another nested subscreen -->
<PreferenceScreen
android:key="button_voicemail_setting_key"
android:title="@string/voicemail_settings"
android:persistent="false">
...
</PreferenceScreen>
<RingtonePreference
android:key="button_voicemail_ringtone_key"
android:title="@string/voicemail_ringtone_title"
android:ringtoneType="notification" ... />
...
</PreferenceScreen>
...
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
这可以使用本机Activity,PreferenceFragment工作正常...但是使用AppCompatActivity和PreferenceFragmentCompat,单击Preference元素只会突出显示它,但不会打开子屏幕.
我在这个文档和代码上找不到任何东西......我需要实现任何额外的回调吗?
编辑:只是为了完整...
这可以工作并打开子屏幕:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new DemoPreferenceFragment())
.commit();
}
}
static public class DemoPreferenceFragment extends PreferenceFragment {
@Override …Run Code Online (Sandbox Code Playgroud) 当我使用向量drawable设置通知的小图标时,我得到以下异常:
android.app.RemoteServiceException:从包com.qbes.xxx发布的错误通知:无法创建图标:StatusBarIcon(pkg = com.qbes.xxxuser = 0 id = 0x7f020082 level = 0 visible = true num = 0)
这是我的代码:
mNotificationBuilder = new android.support.v4.app.NotificationCompat.Builder(this)
.setDefaults(android.support.v4.app.NotificationCompat.DEFAULT_LIGHTS)
.setSound(null)
.setSmallIcon(R.drawable.logo_white)
.setColor(getResources().getColor(R.color.colorPrimary))
.setCategory(android.support.v4.app.NotificationCompat.CATEGORY_PROGRESS)
.setContentTitle("Trip in Progress...")
.setAutoCancel(false)
.setProgress(0, 0, progress)
.setOngoing(true)
.setPriority(android.support.v4.app.NotificationCompat.PRIORITY_MAX)
.setOnlyAlertOnce(true)
.setContentIntent(pendingIntent);
mNotificationBuilder.setContentText(body);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = mNotificationBuilder.build();
mNotificationManager.notify(Constants.NOTIFICATION_ID_Dash, note);
Run Code Online (Sandbox Code Playgroud)
和我build.gradle(仅相关部分):
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.qbes.xxx"
minSdkVersion 16
targetSdkVersion 22
versionCode 720
versionName "0.7.20"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled …Run Code Online (Sandbox Code Playgroud) java android android-appcompat android-notifications android-support-library
我在Android应用程序的工作,我现在用ActionBar这样一个有导航是抽屉图标来打开它和标题ActionBar在ActionBar.我想在标题上设置一个点击监听器ActionBar,使其Activity在导航抽屉图标上启动一个新的并设置不同的点击监听器,以打开导航抽屉菜单.
我点击了导航抽屉图标但是当我点击标题ActionBar标题时它也会打开导航抽屉菜单.有没有办法在标题上设置不同的点击监听器ActionBar.
提前致谢.
android android-appcompat android-actionbar android-actionbar-compat android-actionbaractivity
如何监听SwitchCompat小部件点击?我想在切换Switch时执行一些语句.
寻找相当于
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Do something
}
});
Run Code Online (Sandbox Code Playgroud) 如果我在gradle中使用vectorDrawables.useSupportLibrary = true,那么不幸地运行它停止的应用程序.如果我删除vectorDrawables.useSupportLibrary = true,该应用程序将起作用.
我的朋友:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "com.helikanon.firstapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.android.support:support-v4:25.1.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.google.android.gms:play-services-ads:10.0.1' …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-support-library android-vectordrawable