在你下注并标记为重复之前,请阅读我的问题.
我已经阅读了讨论这个问题的其他问题,所有问题都适用于我的布局,除了第一个创建的布局.
目前,这是我onCreate方法的首要任务:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Run Code Online (Sandbox Code Playgroud)
^这使得它至少在启动时没有弹出键盘,但EditText仍然专注于.
这是XML我的EditText:
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/changePass"
android:layout_centerHorizontal="true"
android:layout_marginTop="167dp"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
android:maxLength="30" >
</EditText>
Run Code Online (Sandbox Code Playgroud)
这是我开展活动时的样子:

问题是,对于某些手机,如果EditText像这样聚焦,他们就无法写入.我希望它不要集中注意力.
我所做的工作适用于下一个布局,因为它EditTexts没有关注,看起来更像是这样:

请注意,它的布局是相同的.这是用户返回到此屏幕后的屏幕,这表示没有任何问题,XML因为这是相同的XML,但问题EditText是仅关注创建活动的时间.
我已经完成了研究,所有其他问题对我没有帮助(他们确实帮助键盘不显示,谢天谢地).我怎样才能使它EditText在启动时看起来像第二个截图,而不是第一个?
double r = 11.631;
double theta = 21.4;
Run Code Online (Sandbox Code Playgroud)
在调试器中,这些显示为11.631000000000000和21.399999618530273.
我怎么能避免这个?
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
Toast.makeText(context, "in android.location.PROVIDERS_CHANGED",
Toast.LENGTH_SHORT).show();
Intent pushIntent = new Intent(context, LocalService.class);
context.startService(pushIntent);
} else {
Toast.makeText(context, "not in android.location.PROVIDERS_CHANGED",
Toast.LENGTH_SHORT).show();
Intent pushIntent = new Intent(context, LocalService.class);
context.startService(pushIntent);
}
}
@Override
public void onLocationChanged(Location arg0) {
}
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中,我需要在打开/关闭gps时触发广播接收器.调查此事并建议在app中实施最好的一个.
我想知道是否可以改变ScrollView的颜色.
我不是指背景颜色或边缘.
我附上了我所指的酒吧的打印屏幕.对我来说,这是透明的.
这是我在xml中定义它的方式:
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:layout_toLeftOf="@+id/personalscores_BackButton"
android:layout_marginRight="0dp" >
Run Code Online (Sandbox Code Playgroud)

我正在尝试在反应应用程序中使用谷歌登录.虽然在应用程序外部使用登录按钮本身很有效,但在自定义SignIn组件中使用它时,我无法按预期工作.当用户登录时,按钮本身应该执行一个data-onsuccess方法.问题是即使登录工作,执行也永远不会到达该方法.
我可能错过了一些反应但我无法找到它.有帮助吗?在下面找到加载所有内容和组件本身的html.
<head>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="1234-real-client-id.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<!-- Here is where everything gets displayed -->
<div id="app"></div>
<!-- The file with the js code -->
<script src="/js/main.js"></script>
</body>
var SignIn = React.createClass({
onSignIn : function (google_user) {
// I want this method to be executed
},
render : function() {
return (
<div className="g-signin2" data-onsuccess={this.onSignIn} data-theme="dark" />
);
}
});
Run Code Online (Sandbox Code Playgroud)
请注意,我没有在这里粘贴不相关的代码;)
目前这是我的scrollbar.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="45"
android:centerColor="@color/blue"
android:endColor="@color/blue"
android:startColor="@color/blue" />
<corners android:radius="8dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这是我的ScrollView:
<ScrollView
android:id="@+id/scrollView1"
android:scrollbarThumbVertical="@drawable/scrollbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/btnBack" >
Run Code Online (Sandbox Code Playgroud)
这是它给我的滚动条.它很好,除了太厚和明显.它在这个截图中可能看起来不是很厚,但它确实如此.

我可以设置ScrollView属性来调整滚动条的宽度/粗细吗?或者我可以在渐变中放置属性吗?
casper.start(URL, function() {
casper.page.injectJs('C:/Users/Mike/Documents/n1k0-casperjs-bc0da16/jquery-1.10.2.min.js');
var names = $('span.author-name');
this.echo(names);
this.exit();
}
Run Code Online (Sandbox Code Playgroud)
ReferenceError:找不到变量:$
我该怎么办?我在创建casper实例时也尝试过这个:
var casper = require('casper').create({
// I've tried both commented lines below
// clientScripts: ['C:/Users/Mike/Documents/n1k0-casperjs-bc0da16/jquery-1.10.2.min.js']
// clientScripts: ['includes/jquery-1.10.2.min.js']
});
Run Code Online (Sandbox Code Playgroud) 我有一个带有EditText和Button的Activity.当用户点击EditText时,会显示键盘,他可以输入一些Text - fine.但是当用户点击按钮时,我希望EditText不再处于焦点状态,即键盘隐藏,直到用户再次点击EditText.
单击按钮后,我该怎么做才能"隐藏EditText的焦点".我可以在按钮的OnClick方法中添加一些代码来做到这一点?
编辑:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/edt_SearchDest"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:textSize="18sp"
android:hint="Enter your look-up here.." />
<Button
android:id="@+id/btn_SearchDest"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="Search" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
最好的祝福
我不知道如何在按钮上设置背景渐变(不将背景渐变设置为图像).这与Android有很大的不同.
这是我必须定义一个可返回梯度方案的类:
import UIKit
extension CAGradientLayer {
func backgroundGradientColor() -> CAGradientLayer {
let topColor = UIColor(red: (0/255.0), green: (153/255.0), blue:(51/255.0), alpha: 1)
let bottomColor = UIColor(red: (0/255.0), green: (153/255.0), blue:(255/255.0), alpha: 1)
let gradientColors: [CGColor] = [topColor.CGColor, bottomColor.CGColor]
let gradientLocations: [Float] = [0.0, 1.0]
let gradientLayer: CAGradientLayer = CAGradientLayer()
gradientLayer.colors = gradientColors
gradientLayer.locations = gradientLocations
return gradientLayer
}
}
Run Code Online (Sandbox Code Playgroud)
我可以使用它来设置我的整个视图的背景,如下所示:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let background = CAGradientLayer().backgroundGradientColor()
background.frame = self.view.bounds
self.view.layer.insertSublayer(background, atIndex: 0)
} …Run Code Online (Sandbox Code Playgroud) 当用户按下软键盘上的"完成"时,键盘将关闭.我希望它只有在某个条件为真时才关闭(例如,密码输入正确).
这是我的代码(为按下"完成"按钮时设置一个监听器):
final EditText et = (EditText)findViewById(R.id.et);
et.setOnEditorActionListener(new OnEditorActionListener()
{
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
if(actionId==EditorInfo.IME_ACTION_DONE)
{
if (et.getText().toString().equals(password)) // they entered correct
{
// log them in
}
else
{
// bring up the keyboard
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Toast.makeText(Main.this, "Incorrect.", Toast.LENGTH_SHORT).show();
}
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
我意识到这不起作用的原因可能是因为它在实际关闭软键盘之前运行此代码,但这就是我需要帮助的原因.我不知道另一种方式.
可能的答案主题可能是:
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
Run Code Online (Sandbox Code Playgroud)
那种事,但我不确定.
解:
EditText et = (EditText)findViewById(R.id.et);
et.setOnEditorActionListener(new OnEditorActionListener()
{
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{ …Run Code Online (Sandbox Code Playgroud) android ×6
java ×2
javascript ×2
android-xml ×1
button ×1
casperjs ×1
focus ×1
gps ×1
ios ×1
jquery ×1
precision ×1
reactjs ×1
scrollbar ×1
scrollview ×1
swift ×1