在我的应用程序中,我目前使用Web视图显示一些内容,然后使用Javascript注入快速填写用户的表单.唯一的问题是,与Chrome自定义标签相比,Webview的速度非常慢.是否可以将Javascript代码注入这些自定义选项卡?
例如,以下是我目前使用的一些代码:
myWebView.loadUrl("javascript:document.getElementById('join_first_name').value='" + name + "';void(0); ");
Run Code Online (Sandbox Code Playgroud) 在这里,我有一个代码块,可以将当前活动的信息发送到另一个活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial);
prefs = getSharedPreferences("com.amrapps.paneraautomate", MODE_PRIVATE);
name = (EditText) findViewById(R.id.name);
lastName = (EditText) findViewById(R.id.lastName);
password = (EditText) findViewById(R.id.password);
final CheckBox passwordReveal = (CheckBox) findViewById
(R.id.checkbox);
passwordReveal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
password.setInputType(129);
}
}
});
}
public void continueButton(View v) {
String stringName = name.getText().toString();
String stringLastName = lastName.getText().toString();
String stringPassword = password.getText().toString();
SharedPreferences.Editor editor = prefs.edit();
prefs.edit().putString("name", stringName).commit();
prefs.edit().putString("lastName", stringLastName).commit(); …
Run Code Online (Sandbox Code Playgroud) 我试图得到所有偶数斐波纳契数的总和.我可以打印出数字,但我无法得到它们的总和.这是在java中.
class driver {
public static void main(String [] args) {
int a;
int b = 0;
int c = 1;
for (int i = 0; i < 10; i++) { // Finds fibonacci sequence
a = b;
b = c;
c = a + b;
if ( c % 2 == 0) { // Check if it's even
int sum = 0;
sum = sum + c;
System.out.println(sum);
}
else {
}
}
}
}
Run Code Online (Sandbox Code Playgroud)