- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用对话框中的一些附加 EditText 字段更新 SQLite 数据库表。我如何在更新游戏表的所有五行中收到以下错误消息。
错误:GamesActivity 类中的方法 updateGames 无法应用错误:GamesActivity 类中的 updateGames 方法无法应用于给定类型;必需:int,int,int,int,int,int,int,String发现:字符串,整数原因:实际参数列表和形式参数列表的长度不同
我知道我很可能错误地为 updateGame 方法创建了参数。由于我对 Javascript 和 Android 编程相当陌生,我似乎找不到纠正这个问题的方法。当我查看 DatabaseHelper 时,我可以看到该方法从未被调用或使用。我假设这是因为我的论点是错误的。
我在下面列出了我的代码。如果有人能看一下并指出我做错了什么,我将不胜感激。
DatabaseHelper.java
import rvogl.ca.tpcui.Database.Models.Bowler;
import rvogl.ca.tpcui.Database.Models.League;
import rvogl.ca.tpcui.Database.Models.Series;
import rvogl.ca.tpcui.Database.Models.Games;
public class DatabaseHelper extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "tpc_database";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(League.CREATE_TABLE);
db.execSQL(Bowler.CREATE_TABLE);
db.execSQL(Series.CREATE_TABLE);
db.execSQL(Games.CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + League.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + Bowler.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + Series.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + Games.TABLE_NAME);
onCreate(db);
}
//League Methods
public long insertLeague(String league) {
//Get Writable Database That We Want To Write Data Too
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(League.COLUMN_NAME, league);
long id = db.insert(League.TABLE_NAME, null, values);
db.close();
return id;
}
public League getLeague(long id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(League.TABLE_NAME,
new String[]{League.COLUMN_ID, League.COLUMN_NAME, League.COLUMN_TIMESTAMP},
League.COLUMN_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
League league = new League(
cursor.getInt(cursor.getColumnIndex(League.COLUMN_ID)),
cursor.getString(cursor.getColumnIndex(League.COLUMN_NAME)),
cursor.getString(cursor.getColumnIndex(League.COLUMN_TIMESTAMP)));
cursor.close();
return league;
}
public List<League> getAllLeagues() {
List<League> leagues = new ArrayList<>();
String selectQuery = "SELECT * FROM " + League.TABLE_NAME + " ORDER BY " +
League.COLUMN_TIMESTAMP + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
League league = new League();
league.setId(cursor.getInt(cursor.getColumnIndex(League.COLUMN_ID)));
league.setName(cursor.getString(cursor.getColumnIndex(League.COLUMN_NAME)));
league.setTimestamp(cursor.getString(cursor.getColumnIndex(League.COLUMN_TIMESTAMP)));
leagues.add(league);
} while (cursor.moveToNext());
}
db.close();
return leagues;
}
public int getLeaguesCount() {
String countQuery = "SELECT * FROM " + League.TABLE_NAME;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
return count;
}
public int updateLeague(League league) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(League.COLUMN_NAME, league.getName());
return db.update(League.TABLE_NAME, values, League.COLUMN_ID + " = ?",
new String[]{String.valueOf(league.getId())});
}
public void deleteLeague(League league) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(League.TABLE_NAME, League.COLUMN_ID + " = ?",
new String[]{String.valueOf(league.getId())});
db.close();
}
//Bowler Methods
public long insertBowler(String bowler) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Bowler.COLUMN_NAME, bowler);
long id = db.insert(Bowler.TABLE_NAME, null, values);
db.close();
return id;
}
public Bowler getBowler(long id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(Bowler.TABLE_NAME,
new String[]{Bowler.COLUMN_ID, Bowler.COLUMN_LEAGUE_ID, Bowler.COLUMN_NAME, Bowler.COLUMN_TIMESTAMP},
Bowler.COLUMN_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Bowler bowler = new Bowler(
cursor.getInt(cursor.getColumnIndex(Bowler.COLUMN_ID)),
cursor.getInt(cursor.getColumnIndex(Bowler.COLUMN_LEAGUE_ID)),
cursor.getString(cursor.getColumnIndex(Bowler.COLUMN_NAME)),
cursor.getString(cursor.getColumnIndex(Bowler.COLUMN_TIMESTAMP)));
cursor.close();
return bowler;
}
public List<Bowler> getAllBowlers() {
List<Bowler> bowlers = new ArrayList<>();
String selectQuery = "SELECT * FROM " + Bowler.TABLE_NAME + " ORDER BY " +
Bowler.COLUMN_TIMESTAMP + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
Bowler bowler = new Bowler();
bowler.setId(cursor.getInt(cursor.getColumnIndex(Bowler.COLUMN_ID)));
bowler.setLeagueId(cursor.getInt(cursor.getColumnIndex(Bowler.COLUMN_LEAGUE_ID)));
bowler.setName(cursor.getString(cursor.getColumnIndex(Bowler.COLUMN_NAME)));
bowler.setTimestamp(cursor.getString(cursor.getColumnIndex(Bowler.COLUMN_TIMESTAMP)));
bowlers.add(bowler);
} while (cursor.moveToNext());
}
db.close();
return bowlers;
}
public int getBowlersCount() {
String countQuery = "SELECT * FROM " + Bowler.TABLE_NAME;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
return count;
}
public int updateBowler(Bowler bowler) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Bowler.COLUMN_NAME, bowler.getName());
return db.update(Bowler.TABLE_NAME, values, Bowler.COLUMN_ID + " = ?",
new String[]{String.valueOf(bowler.getId())});
}
public void deleteBowler(Bowler bowler) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(Bowler.TABLE_NAME, Bowler.COLUMN_ID + " = ?",
new String[]{String.valueOf(bowler.getId())});
db.close();
}
//Series Methods
public long insertSeries(String series) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Series.COLUMN_NAME, series);
long id = db.insert(Series.TABLE_NAME, null, values);
db.close();
return id;
}
public Series getSeries(long id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(Series.TABLE_NAME,
new String[]{Series.COLUMN_ID, Series.COLUMN_LEAGUE_ID, Series.COLUMN_NAME, Series.COLUMN_TIMESTAMP},
Series.COLUMN_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Series series = new Series(
cursor.getInt(cursor.getColumnIndex(Series.COLUMN_ID)),
cursor.getInt(cursor.getColumnIndex(Series.COLUMN_LEAGUE_ID)),
cursor.getString(cursor.getColumnIndex(Series.COLUMN_NAME)),
cursor.getString(cursor.getColumnIndex(Series.COLUMN_TIMESTAMP)));
cursor.close();
return series;
}
public List<Series> getAllSeries() {
List<Series> series = new ArrayList<>();
String selectQuery = "SELECT * FROM " + Series.TABLE_NAME + " ORDER BY " +
Series.COLUMN_TIMESTAMP + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
//Looping Through All Rows And Adding To The List
if (cursor.moveToFirst()) {
do {
Series series1 = new Series();
series1.setId(cursor.getInt(cursor.getColumnIndex(Series.COLUMN_ID)));
series1.setLeagueId(cursor.getInt(cursor.getColumnIndex(Series.COLUMN_LEAGUE_ID)));
series1.setName(cursor.getString(cursor.getColumnIndex(Series.COLUMN_NAME)));
series1.setTimestamp(cursor.getString(cursor.getColumnIndex(Series.COLUMN_TIMESTAMP)));
series.add(series1);
} while (cursor.moveToNext());
}
db.close();
return series;
}
public int getSeriesCount() {
String countQuery = "SELECT * FROM " + Series.TABLE_NAME;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
return count;
}
public int updateSeries(Series series) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Series.COLUMN_NAME, series.getName());
return db.update(Series.TABLE_NAME, values, Series.COLUMN_ID + " = ?",
new String[]{String.valueOf(series.getId())});
}
public void deleteSeries(Series series) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(Series.TABLE_NAME, Series.COLUMN_ID + " = ?",
new String[]{String.valueOf(series.getId())});
db.close();
}
//Games Methods
public long insertGames(String games) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Games.COLUMN_SCORE, getGamesCount());
values.put(Games.COLUMN_STRIKES, getGamesCount());
values.put(Games.COLUMN_SPARES, getGamesCount());
values.put(Games.COLUMN_SPLITS, getGamesCount());
values.put(Games.COLUMN_SPLIT_CONVERSIONS, getGamesCount());
values.put(Games.COLUMN_OPEN_FRAMES, getGamesCount());
values.put(Games.COLUMN_TIMESTAMP, getGamesCount());
long id = db.insert(Games.TABLE_NAME, null, values);
db.close();
return id;
}
public Games getGames(long id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(Games.TABLE_NAME,
new String[]{Games.COLUMN_ID, Games.COLUMN_LEAGUE_ID, Games.COLUMN_SCORE, Games.COLUMN_STRIKES, Games.COLUMN_SPARES, Games.COLUMN_SPLITS, Games.COLUMN_SPLIT_CONVERSIONS, Games.COLUMN_OPEN_FRAMES, Games.COLUMN_TIMESTAMP},
Series.COLUMN_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Games games = new Games(
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_ID)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_LEAGUE_ID)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SCORE)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_STRIKES)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPARES)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPLITS)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPLIT_CONVERSIONS)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_OPEN_FRAMES)),
cursor.getString(cursor.getColumnIndex(Games.COLUMN_TIMESTAMP)),
cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPARES)));
cursor.close();
return games;
}
public List<Games> getAllGames() {
List<Games> games = new ArrayList<>();
String selectQuery = "SELECT * FROM " + Games.TABLE_NAME + " ORDER BY " +
Games.COLUMN_TIMESTAMP + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
Games games1 = new Games();
games1.setId(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_ID)));
games1.setLeagueId(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_LEAGUE_ID)));
games1.setScore(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SCORE)));
games1.setStrikes(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_STRIKES)));
games1.setSpares(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPARES)));
games1.setSplits(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPLITS)));
games1.setSplitConversions(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_SPLIT_CONVERSIONS)));
games1.setOpenFrames(cursor.getInt(cursor.getColumnIndex(Games.COLUMN_OPEN_FRAMES)));
games1.setTimestamp(cursor.getString(cursor.getColumnIndex(Games.COLUMN_TIMESTAMP)));
games.add(games1);
} while (cursor.moveToNext());
}
db.close();
return games;
}
public int getGamesCount() {
String countQuery = "SELECT * FROM " + Games.TABLE_NAME;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
return count;
}
public int updateGames(Games games) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(Games.COLUMN_SCORE, games.getScore());
values.put(Games.COLUMN_STRIKES, games.getStrikes());
values.put(Games.COLUMN_SPARES, games.getSpares());
values.put(Games.COLUMN_SPLITS, games.getSplits());
values.put(Games.COLUMN_SPLIT_CONVERSIONS, games.getSplitConversions());
values.put(Games.COLUMN_OPEN_FRAMES, games.getOpenFrames());
return db.update(Games.TABLE_NAME, values, Games.COLUMN_ID + " = ?",
new String[]{String.valueOf(games.getId())});
}
public void deleteGames(Games games) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(Games.TABLE_NAME, Games.COLUMN_ID + " = ?",
new String[]{String.valueOf(games.getId())});
db.close();
}
}
数据库.Models.Games.java
public class Games {
public static final String TABLE_NAME = "Games";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_LEAGUE_ID = "league_id";
public static final String COLUMN_SCORE = "score";
public static final String COLUMN_STRIKES = "strikes";
public static final String COLUMN_SPARES = "spare";
public static final String COLUMN_OPEN_FRAMES = "openframes";
public static final String COLUMN_SPLITS = "plits";
public static final String COLUMN_SPLIT_CONVERSIONS = "splitconversions";
public static final String COLUMN_TIMESTAMP = "timestamp";
private int id;
private int league_id;
private int score;
private int strikes;
private int spares;
private int openframes;
private int splits;
private int splitconversions;
private String timestamp;
public static final String CREATE_TABLE =
"CREATE TABLE " + TABLE_NAME + "("
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COLUMN_LEAGUE_ID + " INTEGER,"
+ COLUMN_SCORE + " INTEGER,"
+ COLUMN_STRIKES + " INTEGER,"
+ COLUMN_SPARES + " INTEGER,"
+ COLUMN_OPEN_FRAMES + " INTEGER,"
+ COLUMN_SPLITS + " INTEGER,"
+ COLUMN_SPLIT_CONVERSIONS + " INTEGER,"
+ COLUMN_TIMESTAMP + " DATETIME DEFAULT CURRENT_TIMESTAMP"
+ ")";
public Games(int anInt, int cursorInt, int i, int anInt1, int cursorInt1, int i1, int anInt2, int cursorInt2, String string, int i2) {
}
public Games() {
this.id = id;
this.league_id = league_id;
this.score = score;
this.strikes = strikes;
this.spares = spares;
this.openframes = openframes;
this.splits = splits;
this.splitconversions = splitconversions;
this.timestamp = timestamp;
}
public int getId() {
return id;
}
public int getLeagueId() { return league_id; }
public int getScore() { return score; }
public int getStrikes() { return strikes; }
public int getSpares() { return spares; }
public int getOpenFrames() { return openframes; }
public int getSplits() { return splits; }
public int getSplitConversions() { return splitconversions; }
public String getTimestamp() {
return timestamp;
}
public void setId(int id) {
this.id = id;
}
public void setLeagueId(int league_id) {
this.league_id = league_id;
}
public void setScore(int score) { this.score = score; }
public void setStrikes(int strikes) { this.strikes = strikes; }
public void setSpares(int spares) { this.spares = spares; }
public void setOpenFrames(int openframes) { this.openframes = openframes; }
public void setSplits(int splits) { this.splits = splits; }
public void setSplitConversions(int splitconversions) { this.splitconversions = splitconversions; }
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
GamesActivity.java
public class GamesActivity extends AppCompatActivity {
private GamesAdapter mAdapter;
private List<Games> gamesList = new ArrayList<>();
private CoordinatorLayout coordinatorLayout;
private RecyclerView recyclerView;
private TextView noGamesView;
private DatabaseHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_games);
coordinatorLayout = findViewById(R.id.coordinator_layout);
recyclerView = findViewById(R.id.recycler_view);
noGamesView = findViewById(R.id.empty_games_view);
db = new DatabaseHelper(this);
gamesList.addAll(db.getAllGames());
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.add_games_fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showGamesDialog(false, null, -1);
}
});
mAdapter = new GamesAdapter(this, gamesList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter);
toggleEmptyGames();
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, final int position) {
}
@Override
public void onLongClick(View view, int position) {
showActionsDialog(position);
}
}));
}
private void createGames(String games) {
long id = db.insertGames(games);
Games n = db.getGames(id);
if (n != null) {
gamesList.add(0, n);
mAdapter.notifyDataSetChanged();
toggleEmptyGames();
}
}
private void updateGames(int score, int strikes, int spares, int splits, int splitconversions, int openframes, int position, String timestamp) {
Games n = gamesList.get(position);
n.setScore(score);
n.setStrikes(strikes);
n.setSpares(spares);
n.setSplits(splits);
n.setSplitConversions(splitconversions);
n.setOpenFrames(openframes);
n.setTimestamp(timestamp);
db.updateGames(n);
gamesList.set(position, n);
mAdapter.notifyItemChanged(position);
toggleEmptyGames();
}
private void deleteGames(int position) {
db.deleteGames(gamesList.get(position));
gamesList.remove(position);
mAdapter.notifyItemRemoved(position);
toggleEmptyGames();
}
private void showActionsDialog(final int position) {
CharSequence colors[] = new CharSequence[]{"Edit", "Delete"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose option");
builder.setItems(colors, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
showGamesDialog(true, gamesList.get(position), position);
} else {
deleteGames(position);
}
}
});
builder.show();
}
private void showGamesDialog(final boolean shouldUpdate, final Games games, final int position) {
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
View view = layoutInflaterAndroid.inflate(R.layout.dialog_game, null);
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(GamesActivity.this);
alertDialogBuilderUserInput.setView(view);
final EditText inputScore = view.findViewById(R.id.etScore);
final EditText inputStrikes = view.findViewById(R.id.etStrikes);
final EditText inputSpares = view.findViewById(R.id.etSpares);
final EditText inputSplits = view.findViewById(R.id.etSplits);
final EditText inputSplitConversions = view.findViewById(R.id.etSplitConversions);
final EditText inputOpenFrames = view.findViewById(R.id.etOpenFrames);
TextView dialogTitle = view.findViewById(R.id.dialog_title);
dialogTitle.setText(!shouldUpdate ? "Enter Game Stats" : "Edit Game Stats");
if (shouldUpdate && games != null) {
inputScore.setText(games.getScore());
inputStrikes.setText(games.getStrikes());
inputSpares.setText(games.getSpares());
inputSplits.setText(games.getSplits());
inputSplitConversions.setText(games.getSplitConversions());
inputOpenFrames.setText(games.getOpenFrames());
}
alertDialogBuilderUserInput
.setCancelable(false)
.setPositiveButton(shouldUpdate ? "update" : "save", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBox, int id) {
}
})
.setNegativeButton("cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBox, int id) {
dialogBox.cancel();
}
});
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
alertDialog.show();
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (shouldUpdate && games != null) {
updateGames(inputScore.getText().toString(), position);
updateGames(inputStrikes.getText().toString(), position);
updateGames(inputSpares.getText().toString(), position);
updateGames(inputSplits.getText().toString(), position);
updateGames(inputSplitConversions.getText().toString(), position);
updateGames(inputOpenFrames.getText().toString(), position);
} else {
createGames(inputScore.getText().toString());
createGames(inputStrikes.getText().toString());
createGames(inputSpares.getText().toString());
createGames(inputSplits.getText().toString());
createGames(inputSplitConversions.getText().toString());
createGames(inputOpenFrames.getText().toString());
}
}
});
}
private void toggleEmptyGames() {
if (db.getGamesCount() > 0) {
noGamesView.setVisibility(View.GONE);
} else {
noGamesView.setVisibility(View.VISIBLE);
}
}
}
如果您需要任何进一步的帮助,请告诉我。
最佳答案
我看起来你应该更换:-
updateGames(inputScore.getText().toString(), position);
updateGames(inputStrikes.getText().toString(), position);
updateGames(inputSpares.getText().toString(), position);
updateGames(inputSplits.getText().toString(), position);
updateGames(inputSplitConversions.getText().toString(), position);
updateGames(inputOpenFrames.getText().toString(), position);
与:-
updateGames(
Integer.parseInt(inputScore.getText().toString()),
Integer.parseInt(inputScore.getText().toString()),
Integer.parseInt(inputSpares.getText().toString()),
Integer.parseInt(inputSplits.getText().toString()),
Integer.parseInt(inputSplitConversions.getText().toString()),
Integer.parseInt(inputOpenFrames.getText().toString()),
position,
String.valueOf(System.currentTimeMillis()) //<<<<< FORMAT GUESSED
);
这将适合 updateGames
方法的签名,即:-
private void updateGames(
int score,
int strikes,
int spares,
int splits,
int splitconversions,
int openframes,
int position,
String timestamp) {
Games n = gamesList.get(position);
n.setScore(score);
n.setStrikes(strikes);
n.setSpares(spares);
n.setSplits(splits);
n.setSplitConversions(splitconversions);
n.setOpenFrames(openframes);
n.setTimestamp(timestamp);
db.updateGames(n);
gamesList.set(position, n);
mAdapter.notifyItemChanged(position);
toggleEmptyGames();
}
它使用db.updateGames(n);
来更新数据库。
如果 EditText 中的值不正确(例如它们必须仅为数字),那么您将收到解析异常。
注意您可能需要调整时间戳的格式以适应。
关于java - 方法 updateGames 类中的 GamesActivity 不能为 App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50418023/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!