我正在尝试更新SQLite数据库中的信息。我的吸气剂读取的信息是正确的,但是每当我去更新记录中的信息时,即联赛名称,基础得分等。我被告知数组的大小为0。
我可以在调试中看到我正在调用正确的记录ID,并且从数据库中提取的信息是正确的。这向我确认记录确实是正确的。
我在调试中看到信息是正确的,并且变量正在存储对记录所做的更改。
看不出我在做什么错。我浏览了本网站上的几篇不同文章,包括这篇文章。What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
我似乎找不到任何能帮助我解决这个问题的东西。有人可以帮我吗,我已经在下面发布了我的代码。
我输入活动后获取记录的代码
public void getLeagueProfile(int position) {
SQLiteOpenHelper database = new DatabaseHelper(this);
SQLiteDatabase db = database.getReadableDatabase();
Cursor viewLeagueProfile = db.query(League.TABLE_NAME, new String[]{League.COLUMN_ID, League.COLUMN_NAME, League.COLUMN_BASE_SCORE, League.COLUMN_BASE_SCORE_PERCENTAGE, League.COLUMN_WINS, League.COLUMN_LOSSES, League.COLUMN_TIMESTAMP}, League.COLUMN_ID + "=?", new String[]{String.valueOf(position)}, null, null, null, null);
if (viewLeagueProfile.moveToFirst()) {
//Prepare League Object
league = new League(viewLeagueProfile.getInt(viewLeagueProfile.getColumnIndex(League.COLUMN_ID)), ln = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_NAME)), bs = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE)), bsp = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE_PERCENTAGE)), lw = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_WINS)), ll = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_LOSSES)), viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_TIMESTAMP)));
Log.e("values : ", ln + ", " + bs + ", " + bsp + ", " + lw + ", " + ll);
final EditText leagueName = findViewById(R.id.etLeagueName);
final EditText basisScore = findViewById(R.id.etBasisScoreValue);
final EditText basisScorePercentage = findViewById(R.id.etBasisScorePercentageValue);
final EditText leagueWins = findViewById(R.id.etLeaguePointsWon);
final EditText leagueLosses = findViewById(R.id.etLeaguePointsLost);
leagueName.setText(ln);
basisScore.setText(bs);
basisScorePercentage.setText(bsp);
leagueWins.setText(lw);
leagueLosses.setText(ll);
Log.v("Cursor Object", DatabaseUtils.dumpCursorToString(viewLeagueProfile));
//Close Database Connection
viewLeagueProfile.close();
}
}
我的代码,用于在单击保存时更新数据库中的记录
private void updateLeague(String ln, String bs, String bsp, String lw, String ll, final int position) {
League n = leaguesList.get(position);
//Updating League Text
n.setName(ln);
n.setBaseScore(bs);
n.setBaseScorePercentage(bsp);
n.setWins(lw);
n.setLosses(ll);
//Updating The League In The Database
db.updateLeague(n);
//Refreshing The List
leaguesList.set(position, n);
mAdapter.notifyItemChanged(position);
}
DatabaseHelper.java中的“我的更新”功能
public int updateLeague(League league) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(League.COLUMN_NAME, league.getName());
values.put(League.COLUMN_BASE_SCORE, league.getBaseScore());
values.put(League.COLUMN_BASE_SCORE_PERCENTAGE, league.getBaseScorePercentage());
values.put(League.COLUMN_WINS, league.getWins());
values.put(League.COLUMN_LOSSES, league.getLosses());
//Updating Row
return db.update(League.TABLE_NAME, values, League.COLUMN_ID + " = ?",
new String[]{String.valueOf(league.getId())});
}
调试控制台日志
09/27 16:29:25: Launching app
No apk changes detected since last installation, skipping installation of D:\Documents\Android Studio Project\tpbcUI\app\build\outputs\apk\debug\app-debug.apk
$ adb shell am force-stop ca.rvogl.tpbcui
$ adb shell am start -n "ca.rvogl.tpbcui/ca.rvogl.tpbcui.views.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: ca.rvogl.tpbcui | ca.rvogl.tpbcui.test
Waiting for application to come online: ca.rvogl.tpbcui | ca.rvogl.tpbcui.test
Connecting to ca.rvogl.tpbcui
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/art: Debugger is active
I/System.out: Debugger has connected
waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8635', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1341)
W/System: ClassLoader referenced unknown path: /data/app/ca.rvogl.tpbcui-2/lib/x86
D/: HostConnection::get() New Host Connection established 0x9cfff640, tid 6650
D/: HostConnection::get() New Host Connection established 0x9bcdf080, tid 6666
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xa0485120: maj 3 min 1 rcv 4
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/ViewConfigCompat: Could not find method getScaledScrollFactor() on ViewConfiguration
D/id: 4
D/leagueId: 4
D/id: 3
D/leagueId: 3
I/art: Do partial code cache collection, code=12KB, data=19KB
I/art: After code cache collection, code=12KB, data=19KB
Increasing code cache capacity to 128KB
I/art: Do partial code cache collection, code=12KB, data=38KB
I/art: After code cache collection, code=12KB, data=38KB
Increasing code cache capacity to 256KB
I/art: JIT allocated 60KB for compiled code of void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
D/id: 2
D/leagueId: 2
D/id: 1
D/leagueId: 1
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
I/art: Do full code cache collection, code=81KB, data=55KB
I/art: Starting a blocking GC JitCodeCache
I/art: After code cache collection, code=79KB, data=43KB
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/leagueId: 0
E/values :: Saturday Practice Bowling, 190, 100, 0, 0
V/Cursor Object: >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@ae7b8b5
0 {
_id=4
name=Saturday Practice Bowling
basescore=190
basescorepercentage=100
wins=0
losses=0
timestamp=2018-09-20 17:58:16
}
<<<<<
E/values :: Saturday Practice Bowling, 190, 100, 0, 0
I/art: Do partial code cache collection, code=118KB, data=89KB
I/art: After code cache collection, code=115KB, data=87KB
Increasing code cache capacity to 512KB
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
D/OpenGLRenderer: endAllActiveAnimators on 0x8b721c80 (MenuPopupWindow$MenuDropDownListView) with handle 0x8cdb7740
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
I/art: Starting a blocking GC Instrumentation
E/values :: Saturday Practice Bowling, 190, 100, 0, 0
V/Cursor Object: >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@66308ae
0 {
_id=4
name=Saturday Practice Bowling
basescore=190
basescorepercentage=100
wins=0
losses=0
timestamp=2018-09-20 17:58:16
}
<<<<<
I/art: JIT allocated 61KB for compiled code of void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
I/art: Do full code cache collection, code=245KB, data=147KB
Starting a blocking GC JitCodeCache
After code cache collection, code=175KB, data=97KB
D/EGL_emulation: eglMakeCurrent: 0xa0485120: ver 3 1 (tinfo 0xa0483130)
如果我错过了发布可以解决此问题的内容,请告诉我,我将很乐意发布。
2018-09-27 16:08:09.615 5820-5820/ca.rvogl.tpbcui E/AndroidRuntime: FATAL EXCEPTION: main
Process: ca.rvogl.tpbcui, PID: 5820
java.lang.IndexOutOfBoundsException: Index: 4, Size: 0
at java.util.ArrayList.get(ArrayList.java:411)
at ca.rvogl.tpbcui.views.LeagueProfileEditActivity.updateLeague(LeagueProfileEditActivity.java:189)
at ca.rvogl.tpbcui.views.LeagueProfileEditActivity.access$000(LeagueProfileEditActivity.java:28)
at ca.rvogl.tpbcui.views.LeagueProfileEditActivity$1.onClick(LeagueProfileEditActivity.java:124)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
我在League n = leaguesList.get(position);
这一行上得到了它
活动代码:
public class LeagueProfileEditActivity extends AppCompatActivity {
League league;
public List<League> leaguesList = new ArrayList<>();
private LeagueAdapter mAdapter;
public DatabaseHelper db;
private static final String PREFS_NAME = "prefs";
private static final String PREF_BLUE_THEME = "blue_theme";
private static final String PREF_GREEN_THEME = "green_theme";
private static final String PREF_ORANGE_THEME = "purple_theme";
private static final String PREF_RED_THEME = "red_theme";
private static final String PREF_YELLOW_THEME = "yellow_theme";
public String ln, bs, bsp, lw, ll;
public int leagueId;
@Override
protected void onResume() {
super.onResume();
db = new DatabaseHelper(this);
//mAdapter.notifyDatasetChanged(db.getAllLeagues());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//Use Chosen Theme
SharedPreferences preferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
boolean useBlueTheme = preferences.getBoolean(PREF_BLUE_THEME, false);
if (useBlueTheme) {
setTheme(R.style.AppTheme_Blue_NoActionBar);
}
boolean useGreenTheme = preferences.getBoolean(PREF_GREEN_THEME, false);
if (useGreenTheme) {
setTheme(R.style.AppTheme_Green_NoActionBar);
}
boolean useOrangeTheme = preferences.getBoolean(PREF_ORANGE_THEME, false);
if (useOrangeTheme) {
setTheme(R.style.AppTheme_Orange_NoActionBar);
}
boolean useRedTheme = preferences.getBoolean(PREF_RED_THEME, false);
if (useRedTheme) {
setTheme(R.style.AppTheme_Red_NoActionBar);
}
boolean useYellowTheme = preferences.getBoolean(PREF_YELLOW_THEME, false);
if (useYellowTheme) {
setTheme(R.style.AppTheme_Yellow_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_league_profile_edit);
mAdapter = new LeagueAdapter(this, leaguesList);
String savedLeagueId = String.valueOf(getIntent().getIntExtra("leagueId",2));
leagueId = Integer.valueOf(savedLeagueId);
getLeagueProfile(leagueId);
final Button save_button = (Button) findViewById(R.id.bSave);
save_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final EditText leagueName = findViewById(R.id.etLeagueName);
final EditText basisScore = findViewById(R.id.etBasisScoreValue);
final EditText basisScorePercentage = findViewById(R.id.etBasisScorePercentageValue);
final EditText leagueWins = findViewById(R.id.etLeaguePointsWon);
final EditText leagueLosses = findViewById(R.id.etLeaguePointsLost);
int leagueId = league.getId();
updateLeague(league, leagueName.getText().toString(), basisScore.getText().toString(), basisScorePercentage.getText().toString(), leagueWins.getText().toString(), leagueLosses.getText().toString(), leagueId);
Intent intent = new Intent(getApplicationContext(), LeagueProfileViewActivity.class);
intent.putExtra("leagueId", leagueId);
startActivity(intent);
finish();
overridePendingTransition(0, 0);
}
});
final Button cancel_button = (Button) findViewById(R.id.bCancel);
cancel_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int leagueId = league.getId();
Intent intent = new Intent(getApplicationContext(), LeagueProfileViewActivity.class);
intent.putExtra("leagueId", leagueId);
startActivity(intent);
finish();
overridePendingTransition(0, 0);
}
});
}
public void getLeagueProfile(int position) {
SQLiteOpenHelper database = new DatabaseHelper(this);
SQLiteDatabase db = database.getReadableDatabase();
Cursor viewLeagueProfile = db.query(League.TABLE_NAME, new String[]{League.COLUMN_ID, League.COLUMN_NAME, League.COLUMN_BASE_SCORE, League.COLUMN_BASE_SCORE_PERCENTAGE, League.COLUMN_WINS, League.COLUMN_LOSSES, League.COLUMN_TIMESTAMP}, League.COLUMN_ID + "=?", new String[]{String.valueOf(position)}, null, null, null, null);
if (viewLeagueProfile.moveToFirst()) {
//Prepare League Object
league = new League(viewLeagueProfile.getInt(viewLeagueProfile.getColumnIndex(League.COLUMN_ID)), ln = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_NAME)), bs = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE)), bsp = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE_PERCENTAGE)), lw = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_WINS)), ll = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_LOSSES)), viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_TIMESTAMP)));
Log.e("values : ", ln + ", " + bs + ", " + bsp + ", " + lw + ", " + ll);
final EditText leagueName = findViewById(R.id.etLeagueName);
final EditText basisScore = findViewById(R.id.etBasisScoreValue);
final EditText basisScorePercentage = findViewById(R.id.etBasisScorePercentageValue);
final EditText leagueWins = findViewById(R.id.etLeaguePointsWon);
final EditText leagueLosses = findViewById(R.id.etLeaguePointsLost);
leagueName.setText(ln);
basisScore.setText(bs);
basisScorePercentage.setText(bsp);
leagueWins.setText(lw);
leagueLosses.setText(ll);
Log.v("Cursor Object", DatabaseUtils.dumpCursorToString(viewLeagueProfile));
//Close Database Connection
viewLeagueProfile.close();
}
}
private void updateLeague(final League league, String ln, String bs, String bsp, String lw, String ll, final int position) {
League n = leaguesList.get(position);
//Updating League Text
n.setName(ln);
n.setBaseScore(bs);
n.setBaseScorePercentage(bsp);
n.setWins(lw);
n.setLosses(ll);
//Updating The League In The Database
db.updateLeague(n);
//Refreshing The List
leaguesList.set(position, n);
mAdapter.notifyItemChanged(position);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.league_profile_edit_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_cancel) {
/*Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
overridePendingTransition(0, 0);*/
return true;
}
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:1)
您的问题是leaguesList
是一个空列表,因此League n = leaguesList.get(position);
试图从0个元素中获取第4个元素。因此是例外。
@MikeT下列代码是否不是填充LeagueListList League League的代码? 私有列表LeaguesList = new ArrayList <>();私人的 LeagueAdapter mAdapter;
否。 League league;
(具有类范围)与private List leaguesList = new ArrayList<>();
无关,只是它们属于同一类型。因此,使用getLeagueProfile(leagueId);
只需设置(实例化)联盟变量/对象。
我不认为您需要LeaguesList和mAdapter。我相信您需要满足以下条件(即只需使用单个联盟变量):-
public class LeagueProfileEditActivity extends AppCompatActivity {
League league;
//public List<League> leaguesList = new ArrayList<>(); //<<<<<<<<<< DELETED
//private LeagueAdapter mAdapter; //<<<<<<<<<< DELETED
public DatabaseHelper db;
private static final String PREFS_NAME = "prefs";
private static final String PREF_BLUE_THEME = "blue_theme";
private static final String PREF_GREEN_THEME = "green_theme";
private static final String PREF_ORANGE_THEME = "purple_theme";
private static final String PREF_RED_THEME = "red_theme";
private static final String PREF_YELLOW_THEME = "yellow_theme";
public String ln, bs, bsp, lw, ll;
public int leagueId;
@Override
protected void onResume() {
super.onResume();
db = new DatabaseHelper(this);
//mAdapter.notifyDatasetChanged(db.getAllLeagues()); //<<<<<<<<<< Not needed
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//Use Chosen Theme
SharedPreferences preferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
boolean useBlueTheme = preferences.getBoolean(PREF_BLUE_THEME, false);
if (useBlueTheme) {
setTheme(R.style.AppTheme_Blue_NoActionBar);
}
boolean useGreenTheme = preferences.getBoolean(PREF_GREEN_THEME, false);
if (useGreenTheme) {
setTheme(R.style.AppTheme_Green_NoActionBar);
}
boolean useOrangeTheme = preferences.getBoolean(PREF_ORANGE_THEME, false);
if (useOrangeTheme) {
setTheme(R.style.AppTheme_Orange_NoActionBar);
}
boolean useRedTheme = preferences.getBoolean(PREF_RED_THEME, false);
if (useRedTheme) {
setTheme(R.style.AppTheme_Red_NoActionBar);
}
boolean useYellowTheme = preferences.getBoolean(PREF_YELLOW_THEME, false);
if (useYellowTheme) {
setTheme(R.style.AppTheme_Yellow_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_league_profile_edit);
//mAdapter = new LeagueAdapter(this, leaguesList); //<<<<<<<<<< not needed
String savedLeagueId = String.valueOf(getIntent().getIntExtra("leagueId",2));
leagueId = Integer.valueOf(savedLeagueId);
getLeagueProfile(leagueId); //<<<<<<<<<< sets the values for league
final Button save_button = (Button) findViewById(R.id.bSave);
save_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final EditText leagueName = findViewById(R.id.etLeagueName);
final EditText basisScore = findViewById(R.id.etBasisScoreValue);
final EditText basisScorePercentage = findViewById(R.id.etBasisScorePercentageValue);
final EditText leagueWins = findViewById(R.id.etLeaguePointsWon);
final EditText leagueLosses = findViewById(R.id.etLeaguePointsLost);
int leagueId = league.getId();
updateLeague(league, leagueName.getText().toString(), basisScore.getText().toString(), basisScorePercentage.getText().toString(), leagueWins.getText().toString(), leagueLosses.getText().toString(), leagueId);
Intent intent = new Intent(getApplicationContext(), LeagueProfileViewActivity.class);
intent.putExtra("leagueId", leagueId);
startActivity(intent);
finish();
overridePendingTransition(0, 0);
}
});
final Button cancel_button = (Button) findViewById(R.id.bCancel);
cancel_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int leagueId = league.getId();
Intent intent = new Intent(getApplicationContext(), LeagueProfileViewActivity.class);
intent.putExtra("leagueId", leagueId);
startActivity(intent);
finish();
overridePendingTransition(0, 0);
}
});
}
public void getLeagueProfile(int position) {
SQLiteOpenHelper database = new DatabaseHelper(this);
SQLiteDatabase db = database.getReadableDatabase();
Cursor viewLeagueProfile = db.query(League.TABLE_NAME, new String[]{League.COLUMN_ID, League.COLUMN_NAME, League.COLUMN_BASE_SCORE, League.COLUMN_BASE_SCORE_PERCENTAGE, League.COLUMN_WINS, League.COLUMN_LOSSES, League.COLUMN_TIMESTAMP}, League.COLUMN_ID + "=?", new String[]{String.valueOf(position)}, null, null, null, null);
if (viewLeagueProfile.moveToFirst()) {
//Prepare League Object
league = new League(viewLeagueProfile.getInt(viewLeagueProfile.getColumnIndex(League.COLUMN_ID)), ln = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_NAME)), bs = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE)), bsp = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_BASE_SCORE_PERCENTAGE)), lw = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_WINS)), ll = viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_LOSSES)), viewLeagueProfile.getString(viewLeagueProfile.getColumnIndex(League.COLUMN_TIMESTAMP)));
Log.e("values : ", ln + ", " + bs + ", " + bsp + ", " + lw + ", " + ll);
final EditText leagueName = findViewById(R.id.etLeagueName);
final EditText basisScore = findViewById(R.id.etBasisScoreValue);
final EditText basisScorePercentage = findViewById(R.id.etBasisScorePercentageValue);
final EditText leagueWins = findViewById(R.id.etLeaguePointsWon);
final EditText leagueLosses = findViewById(R.id.etLeaguePointsLost);
leagueName.setText(ln);
basisScore.setText(bs);
basisScorePercentage.setText(bsp);
leagueWins.setText(lw);
leagueLosses.setText(ll);
Log.v("Cursor Object", DatabaseUtils.dumpCursorToString(viewLeagueProfile));
//Close Database Connection
viewLeagueProfile.close();
}
}
private void updateLeague(final League league, String ln, String bs, String bsp, String lw, String ll, final int position) {
//League n = leaguesList.get(position); //<<<<<<<<<<<<<<<<<<< ERROR
//Updating League Object
//n.setName(ln); //<<<<<<<<<< replaced by
league.setName(ln)
//n.setBaseScore(bs); //<<<<<<<<<< replaced by
league.setBaseScore(bs);
//n.setBaseScorePercentage(bsp); //<<<<<<<<<< replaced by
league.setBaseScorePercentage(bsp);
//n.setWins(lw); //<<<<<<<<<< replaced by
league.setWinds(lw);
//n.setLosses(ll); //<<<<<<<<<< replaced by
league.setLosses(ll);
//Updating The League In The Database
db.updateLeague(league);
//Refreshing The List
//leaguesList.set(position, n); //<<<<<<<<<< DELETED NOT USED????
//mAdapter.notifyItemChanged(position); //<<<<<<<<<< DELETED NOT USED????
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.league_profile_edit_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_cancel) {
/*Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
overridePendingTransition(0, 0);*/
return true;
}
return super.onOptionsItemSelected(item);
}
}