在Android Studio中有任何自动导入方式(如在Eclipse Shift+ Ctrl+中O)吗?
我发现只有Ctrl+ Alt+ O要求每个东西,我必须按Alt+ Enter接受它.
没办法做得更快?
我应该如何提供EditText的ID来填充Google Play上的发布前报告的凭据(应用的Beta/Alpha版本)?我试过
@+id/editTextLogin
,editTextLogin
,R.id.editTextLogin
,一定可以得到说明"错误的资源名称".
什么是资源名称的正确架构?
我Snackbar
在平板电脑(API 22)上设置有问题,在手机(API 23和22)上工作正常(从边缘到边缘),即使在水平时也是如此.结果是如下Snackbar:
FloatingActionButton(支持库)也不会移动(当它在手机上时).
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/snackParent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="@dimen/margin_fab"
android:layout_marginRight="@dimen/margin_fab"
app:pressedTranslationZ="12dp" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
并在MainActivity中使用
private void showMessage(String msg) {
if(snackParent != null) {
snackbar = Snackbar.make(snackParent, msg, Snackbar.LENGTH_SHORT);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
}
});
snackbar.show();
}
}
Run Code Online (Sandbox Code Playgroud)
我只有平板电脑尺寸(工厂边距)的其他资源文件(w820dp),手机和平板电脑之间的样式文件夹相同.我也试过使Android Studio缓存无效.我使用com.android.support:design:23.0.1
targetSdkVersion = 23和compileSdkVersion = 23,buildToolsVersion = 23.0.1.
android android-support-library floating-action-button android-snackbar
以编程方式设置"主题切换器"时遇到一些困难.我想从app(白色(Theme.Light.NoTitleBar)和Dark(Theme.Black.NoTitleBar)之间)切换主题,我的工作是:我设置了一个SharedPreference:
final String PREFS_NAME = "MyPrefsFile";
final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
final SharedPreferences.Editor editor = settings.edit();
Run Code Online (Sandbox Code Playgroud)
而且我有两个按钮来切换主题(第二个几乎相同)
Button ThemeWhite = (Button) findViewById(R.id.ThemeWhite);
ThemeWhite.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
editor.putBoolean("Theme", false);
editor.commit();
System.exit(2);
}
});
Run Code Online (Sandbox Code Playgroud)
在每个活动的乞讨中,我检查SharedPreference
boolean theme = settings.getBoolean("Theme", false);
if(theme){
this.setTheme(R.style.Theme_NoBarBlack);
} else{
this.setTheme(R.style.Theme_NoBar);
}
setContentView(R.layout.aplikacja);
Run Code Online (Sandbox Code Playgroud)
我在文件styles.xml中定义文件夹值中的主题:
<resources>
<style name="Theme.NoBar" parent="@android:style/Theme.Light.NoTitleBar" />
<style name="Theme.NoBarBlack" parent="@android:style/Theme.NoTitleBar" />
Run Code Online (Sandbox Code Playgroud)
在值-v11中:
<resources>
<style name="Theme.NoBar" parent="@android:style/Theme.Holo.Light.NoActionBar" />
<style name="Theme.NoBarBlack" parent="@android:style/Theme.Holo.NoActionBar" />
Run Code Online (Sandbox Code Playgroud)
在值-v14中:
<resources>
<style name="Theme.NoBar" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar" />
<style name="Theme.NoBarBlack" …
Run Code Online (Sandbox Code Playgroud) 有没有办法限制用户可以选择他/她的位置的Google Place Picker区域?
像当前位置的半径.
有什么区别:getEventTime()和getDownTime()?在文档http://developer.android.com/reference/android/view/MotionEvent.html 两者似乎做同样的事情,但他们输出不同的值.
突然(这个项目代码没有任何变化)我开始得到一个错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{<package>}: java.lang.IllegalArgumentException: Button does not exist
Run Code Online (Sandbox Code Playgroud)
该错误指向尚未调用的方法.
private void dialog(String title, String content){
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(title);
alertDialog.setMessage(content);
alertDialog.setCancelable(true);
alertDialog.setButton(1, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
Run Code Online (Sandbox Code Playgroud)
我试图在其他项目中复制并使用该代码 - 结果相同,并且它不久前工作(相同的目标API等).知道我在忽视什么吗?
我正在使用Sinch SDK进行即时消息传递.如何注销用户?我有按钮注销用户,但无法在Sinch SDK中实现该功能.他们的文档或样本都没有描述这样的特征.
我有建立自己的字体为我的ListView的问题,我不知道如何使用自己的适配器类和XML是什么,我需要(除了一个在我把ListView控件).我希望(在ListView中)只为具有自己字体的居中文本.那是我的适配器:
public class MyAdapter extends BaseAdapter {
private String[] objects; // no objects just String array
private final Context context;
public MyAdapter(Context context, String[] objects) {
this.context = context;
this.objects = objects;
}
@Override
public int getCount() {
return objects.length;
}
@Override
public Object getItem(int position) {
return objects[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Object obj = objects[position];
TextView tv = new TextView(context);
tv.setText(obj.toString());
Typeface …
Run Code Online (Sandbox Code Playgroud) 我无法弄清楚这是如何工作的:如果我创建了一个名为的文件夹layout-v11
,这将适用于从v11向上或仅到v11的所有api版本?第二个我可以将文件夹命名layout-v11-v14
为仅使用此布局用于v11和v14 API吗?
android ×9
auto-import ×1
fonts ×1
google-play ×1
ide ×1
messaging ×1
sinch ×1
styles ×1
themes ×1