我有一个方法,用于显示最高值,并显示它所属的索引号.到目前为止,它已经可以显示最高值,但索引号无法显示.我该怎么办才能让系统显示i价值呢?
private void pick_highest_value_here_and_display(ArrayList<Double> value) throws Exception {
// TODO Auto-generated method stub
double aa[]=value.stream().mapToDouble(v -> v.doubleValue()).toArray();
double highest=Double.MIN_VALUE;
System.out.println(highest);
for(int i=0;i<aa.length;i++)
{
if(aa[i]>highest)
{
highest=aa[i];
}
}
System.out.println(highest);
System.out.println(i); // Error: create local variable i
}
Run Code Online (Sandbox Code Playgroud) 这只是一个基本的问答应用.当我试图radiobutton在应用程序界面上按下时,我收到错误.这是我的主要课程:
public class Balance extends AppCompatActivity {
private int score = 0; //answer score
private int PreviousScore;
private int i = 0;
private Vibrator myVib;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_balance);
final TextView Score = (TextView) findViewById(R.id.Score);
Button b = (Button)findViewById(R.id.button); //button
myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
question(); //call params for question
//button listener, when button clicked, produce output on textfield "Score"
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) { …Run Code Online (Sandbox Code Playgroud) 为button Back和button Delete,我setBounds到(130,120,195,30) ; 和(10,190,195,30); ,但他们仍然没有走到谷底.
这有什么不对?
public deleteAdmin(int num)
{
super("Delete Admin");
setBounds(100, 200, 340, 229);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JPanel panel = new JPanel();
panel.setBounds(35, 19, 242, 146);
contentPane.add(panel);
JButton button = new JButton("Back");
button.setBounds(130, 120, 195,30);
panel.add(button);
JButton bckButton = new JButton("Delete");
bckButton.setBounds(10, 190, 195,30);
panel.add(bckButton);
adminAPI admin = new adminAPI();
List<String>allName = null;
try {
allName= admin.displayName();
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud) 我试图在一段时间后在ionic2中实现提醒/报警.我已经找到了这个插件https://github.com/wnyc/cordova-plugin-wakeuptimer但是我想用typescript 来实现它,因为这是无法识别的window.wakeuptimer在下面提到的代码中使用:
window.wakeuptimer.wakeup( successCallback,
errorCallback,
// a list of alarms to set
{
alarms : [{
type : 'onetime',
time : { hour : 14, minute : 30 },
extra : { message : 'json containing app-specific information to be posted when alarm triggers' },
message : 'Alarm has expired!'
}]
}
);
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我
我的片段流是这样的
Main -> A -> B -> C ->A
Run Code Online (Sandbox Code Playgroud)
在片段c中,它具有一个提交按钮,该按钮将返回到A。当我在A中按下后退按钮时,我希望它返回到Main。但是它返回片段c。
在片段C中,我使用了
findNavController().navigate(R.id.action_c_to_a)
Run Code Online (Sandbox Code Playgroud)
nav_graph.xml
<fragment
android:id="@+id/fragmentC"
android:name="xxx"
android:label="xxx">
<action
app:launchSingleTop="true"
app:popUpTo="@+id/fragmentA"
app:popUpToInclusive="true"
android:id="@+id/action_c_to_a"
app:destination="@id/fragmentA" />
</fragment>
Run Code Online (Sandbox Code Playgroud) 我有5个复选框,我已将选择限制为仅3.每个所选复选框的列表值将存储到数据库中,如果列表少于3个,则用零填充列表.如何用零填充列表?
List < Integer > preferences = new ArrayList < Integer > ();
if (chckbxLei.isSelected()) {
preferences.add(Integer.valueOf(chckbxLei.getName()));
}
if (chckbxAdv.isSelected()) {
preferences.add(Integer.valueOf(chckbxAdv.getName()));
}
if (chckbxHis.isSelected()) {
preferences.add(Integer.valueOf(chckbxHis.getName()));
}
if (chckbxOut.isSelected()) {
preferences.add(Integer.valueOf(chckbxOut.getName()));
}
if (chckbxFAK.isSelected()) {
preferences.add(Integer.valueOf(chckbxFAK.getName()));
}
if (preferences.size() > 3) {
JOptionPane.showMessageDialog(frame,
"Please Select Only 3! ");
return;
}
Place place = new Place();
try {
place.addPre(preferences);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
Place.java
public void addPre(List < Integer > preferences) throws …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Android的PHP和MySQL开发一个完整的Android登录注册系统.如果用户忘记了密码,则会向他的电子邮件发送新密码.我按照本教程.
忘记密码
email = (EditText) findViewById(R.id.forpas);
forgetPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if ((name.getText().toString().trim().length() == 0) || (email.getText().toString().trim().length() == 0)) {
Toast.makeText(getApplicationContext(), "Name or E-mail cannot be null", Toast.LENGTH_LONG).show();
return;
} else {
NetAsync();
}
}
});
private class NetCheck extends AsyncTask
{
private ProgressDialog nDialog;
@Override
protected void onPreExecute(){
super.onPreExecute();
nDialog = new ProgressDialog(ForgetPassword.this);
nDialog.setMessage("Loading..");
nDialog.setTitle("Checking Network");
nDialog.setIndeterminate(false);
nDialog.setCancelable(true);
nDialog.show();
}
@Override
protected Boolean doInBackground(String... args){
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = …Run Code Online (Sandbox Code Playgroud) 我使用下面的查询创建了一个 SQLite 表
db.execSQL("create table " + TABLE__WORK + " ( " + ID1 + " INTEGER PRIMARY KEY ,Name TEXT, Title TEXT, Time TEXT, Date TEXT)");
Run Code Online (Sandbox Code Playgroud)
ID 现在可以自动递增。但是在我执行删除查询后,删除第一行数据并再次添加,ID将从而1不是2. 是否有可能使 id 成为2?
“包含:-1”在范围错误中是什么意思
RangeError (index): Invalid Value: Not in range 0..6, inclusive: -1
注意:索引是来自
ListView.builder(
itemBuilder: (context,index) => Widget,
)
Run Code Online (Sandbox Code Playgroud) 我的代码如下
private fun validateInput(): Boolean {
if (etReportRow1.text.toString() == ""
|| etReportRow2.text.toString() == ""
|| etReportRow3.text.toString() == "")
return false
else
return true
}
Run Code Online (Sandbox Code Playgroud)
编译器告诉我
冗余'if'语句减去...(Ctrl + F1)此检查报告if语句是否可以简化为单个语句.例如:if(foo()){return true} else {return false}可以简化为返回foo().
建议的代码不会进入循环吗?
我有这个代码
if (obj.due_date != null) {
print('The date is '+obj.due_date);
print('now change to ' +
DateUtil().formattedDate(DateTime.parse(obj.due_date)));
}
Run Code Online (Sandbox Code Playgroud)
日期工具
import 'package:intl/intl.dart';
class DateUtil {
static const DATE_FORMAT = 'dd/MM/yyyy';
String formattedDate(DateTime dateTime) {
print('dateTime ($dateTime)');
return DateFormat(DATE_FORMAT).format(dateTime);
}
}
Run Code Online (Sandbox Code Playgroud)
我的输出变成这样
I/flutter ( 5209): 日期是 2019-11-20T00:00:00.000+08:00
I/flutter ( 5209): dateTime (2019-11-19 16:00:00.000Z)
I/flutter ( 5209):现在更改为 19/11/2019
为什么它会从 20 变为 19?
我正在使用 Flutter 自己创建一个待办事项应用程序。当我编译并尝试在 sqlite 数据库中插入数据时,出现此错误Flutter Sqlite Exception,No such table task, SQL logic Error。
注意:我使用moor_ffi, moor
,并database.g.dart使用 command生成文件flutter packages pub run build_runner build。
android ×6
java ×5
flutter ×3
dart ×2
kotlin ×2
arrays ×1
checkbox ×1
cordova ×1
datetime ×1
flutter-moor ×1
fragment ×1
if-statement ×1
ionic2 ×1
json ×1
listview ×1
maxlength ×1
mysql ×1
navigation ×1
overriding ×1
primary-key ×1
reminders ×1
sql ×1
sqlite ×1
swing ×1