我正在创建一个自定义的EditText类,因为我需要设置一些自定义字体; 但是现在当我点击editText时,android键盘不再弹出...
这是我的班级:
package ro.gebs.captoom.utils.fonts;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import ro.gebs.captoom.R;
public class CustomFontEditText extends EditText {
private Context context;
public CustomFontEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (!isInEditMode()) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomFontEditText,
defStyle, 0);
assert a != null;
int fontId = a.getInteger(R.styleable.CustomFontEditText_fontNameEdit, -1);
if (fontId == -1) {
throw new IllegalArgumentException("The font_name attribute is required and must refer "
+ "to a valid …Run Code Online (Sandbox Code Playgroud) android android-custom-view android-input-method android-edittext
截至昨天的Google IO Keynote,我们在项目中进行UI测试的方式似乎有了重大更新.
由于采用了新的测试记录功能,自动测试即将迈出一大步.开发人员将能够开始录制并开始使用他们的应用程序.在执行每个操作时,它会转换为Espresso代码,可以在多个平台上播放,包括Google的云测试实验室.这可能会缩短将测试编写为过去十分之一的时间.
我安装了最新版本的Android Studio 2.2 Preview 1,我想知道如何启用此功能.
testing android ui-testing android-espresso android-espresso-recorder
有没有办法在滚动ViewPager的项目时锁定ListView的垂直滚动?或者也许更改ViewPager的水平滚动灵敏度?
谢谢.
最后的编辑
这是我更新的解决方案.感谢您回复Masoud Dadashi,您的评论最终让我想出了解决问题的方法.
这是我的自定义ListView类:
public class FolderListView extends ListView {
private float xDistance, yDistance, lastX, lastY;
// If built programmatically
public FolderListView(Context context) {
super(context);
// init();
}
// This example uses this method since being built from XML
public FolderListView(Context context, AttributeSet attrs) {
super(context, attrs);
// init();
}
// Build from XML layout
public FolderListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// init();
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) { …Run Code Online (Sandbox Code Playgroud) 这个问题涉及这里找到的SwipeListView组件:https://github.com/47deg/android-swipelistview
在尝试了我在网上找到的几个实现和修复后,我决定稍微修改一下这些来源.
我会在这里发布这个,因为我知道这是一个已知的问题,我发现的所有版本最终都有一些问题.
SwipeListViewTouchListener.java 遭受了以下变化:
...
/**
* Create reveal animation
*
* @param view affected view
* @param swap If will change state. If "false" returns to the original
* position
* @param swapRight If swap is true, this parameter tells if movement is toward
* right or left
* @param position list position
*/
private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight, final int position) {
int moveTo = 0;
if (opened.get(position)) …Run Code Online (Sandbox Code Playgroud) 在我尝试运行一些espresso测试后更新到Android Studio 2.3后,我收到以下错误:
测试运行失败:无法找到以下内容的检测信息:ComponentInfo {com.example.android/android.test.InstrumentationTestRunner}空测试套件.
这在过去很容易解决,在运行配置中我可以指定我自己的InstrumentationRunner.现在我似乎无法找到这个选项,所以我现在无法真正指定我的跑步者类.
请注意,我的构建gradle确实包含
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "en", "es"
}
Run Code Online (Sandbox Code Playgroud) 更新我的活动日志
最后的编辑
在尝试了所有可能的解决方案之后,我发现我已经完全安装了Windows.这样做我注意到这是一个防火墙问题,我的防病毒软件阻止了studio64.exe process.
我刚刚安装了Android Studio 0.4.2,然后立即更新到0.5.2而无需打开或创建任何新项目.
我更新了Android SDK,然后创建了一个新项目.即使我试图更改本地gradle分发,我仍然收到Gradle Refresh失败的错误,似乎没有任何工作,我尝试Gradle回复的所有内容:"请修复您的Gradle配置"...
这件事发生在我身上,因为我从未更新到Android工作室5.1.
我尝试使用Gradle 1.10和1.11以及安装工具包中包含的Gradle包装器,可从网站http://developer.android.com/sdk/installing/studio.html下载
这是我的gradle文件:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)
和外部build.gradle文件.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories { …Run Code Online (Sandbox Code Playgroud) 我试图在android中显示一个窗口选择器对话框,默认选择是"无"当前如何,选择默认手机的闹钟/铃声.
这是我试过的代码:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
RingtoneManager.TYPE_NOTIFICATION
| RingtoneManager.TYPE_RINGTONE);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
startActivityForResult(intent, 0);
Run Code Online (Sandbox Code Playgroud)
有关详情,请参见屏幕截图
默认情况下,espresso会在执行下一条指令之前等待我的活动中的进度条完成加载.
我想强制Espresso不要等待它并在加载进度对话框时执行其余的指令.
关于我应该寻找的任何点击?
经过一些调查后,我认为我必须利用这门IdlingResource课程.
我正在尝试使用Google API v2检索我的位置地址.
这是我做的:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
String addressText = "";
try {
while (addresses==null){
addresses = geocoder.getFromLocation(userLocation.latitude,
userLocation.longitude, 1);
}
if (addresses != null && addresses.size() > 0) {
Address address = addresses.get(0);
addressText = String.format(
"%s, %s, %s",
address.getMaxAddressLineIndex() > 0 ? address
.getAddressLine(0) : "", address
.getLocality(), address.getCountryName());
}
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我已阅读了几篇帖子,发现getFromLocation()请求并不总是检索结果.所以我尝试循环.
这不会崩溃但是addressText总是"",任何想法为什么?INTERNET权限已经提供给我的应用程序.我不使用GPS.
userLocation不是null,所以这不是问题,我使用它来添加标记到地图,它工作正常.这似乎是地理编码器严格的问题.
我的导航抽屉让我感到很沮丧.我使用自定义布局,不仅包含通常的列表视图!
每当我点击抽屉部分中的某些部分时,后面列表视图中的行都会被点击.我怎么能禁用它?
解决方案:
只需android:clickable="true"在listview外的抽屉中设置父布局,一切正常.
谢谢你的回答.
android ×10
testing ×2
automation ×1
google-maps ×1
gradle ×1
onclick ×1
ringtone ×1
swipe ×1
ui-testing ×1