收藏夹测试ExpandableListView控件

This commit is contained in:
sonichy
2023-03-23 12:40:08 +08:00
parent 489f00f4a3
commit c962451642
7 changed files with 114 additions and 97 deletions

View File

@@ -159,7 +159,7 @@ public class FavoriteActivity extends Activity {
if (radioButton == null)
break;
final String title = radioButton.getText().toString();
if (title.equals("无分类"))
if (title.equals(""))
break;
builder.setTitle(title);
final EditText editText_rename = new EditText(FavoriteActivity.this);
@@ -291,9 +291,8 @@ public class FavoriteActivity extends Activity {
layout.addView(editText_url);
final Spinner spinner = new Spinner(this);
ArrayList<String> list = new ArrayList<>();
list.add("");
DBHelper helper = new DBHelper(this);
Cursor cursor = helper.category("");
Cursor cursor = helper.category();
if (cursor != null) {
while (cursor.moveToNext()) {
String s = cursor.getString(cursor.getColumnIndex("category"));
@@ -327,19 +326,21 @@ public class FavoriteActivity extends Activity {
values.put("website", surl);
values.put("title", stitle);
values.put("category", spinner.getSelectedItem().toString());
db.update(DBHelper.TableName, values, "_id = " + sid, null);
IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0);
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
if (radioButton == null)
search(0, editText.getText().toString());
else
search(1, radioButton.getText().toString());
try {
//关闭
field.set(dialog, true);
dialog.dismiss();
} catch (Exception ex) {
}
int i = db.update(DBHelper.TableName, values, "_id = " + sid, null);
if (i != -1) {
IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0);
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
if (radioButton == null)
search(0, editText.getText().toString());
else
search(1, radioButton.getText().toString());
try { //关闭
field.set(dialog, true);
dialog.dismiss();
} catch (Exception ex) {
}
} else
Toast.makeText(getApplicationContext(), "修改失败", Toast.LENGTH_SHORT).show();
} else {
if (stitle.equals("")){
editText_title.setError("标题不能为空!");
@@ -380,8 +381,11 @@ public class FavoriteActivity extends Activity {
position = listView.getFirstVisiblePosition();
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
helper = new DBHelper(getApplicationContext());
helper.del(id);
search(0, editText.getText().toString());
int i = helper.del(id);
if (i != -1)
search(0, editText.getText().toString());
else
Toast.makeText(getApplicationContext(), "删除失败", Toast.LENGTH_SHORT).show();
break;
}
return true;
@@ -414,7 +418,7 @@ public class FavoriteActivity extends Activity {
if (type == 0) {
cursor1 = helper.query(s);
} else if (type == 1) {
cursor1 = helper.queryCategoty(s);
cursor1 = helper.queryCategory(s);
}
int count = cursor1.getCount();
setTitle("收藏夹 - " + s + " " + count);
@@ -449,15 +453,11 @@ public class FavoriteActivity extends Activity {
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
radioGroup.removeAllViews();
DBHelper helper = new DBHelper(this);
Cursor cursor = helper.category("");
Cursor cursor = helper.category();
if (cursor != null) {
RadioButton radioButton = new RadioButton(this);
radioButton.setText("无分类");
radioButton.setOnClickListener(new RadioButtonOnClickListener());
radioGroup.addView(radioButton);
while (cursor.moveToNext()) {
String s = cursor.getString(cursor.getColumnIndex("category"));
radioButton = new RadioButton(this);
RadioButton radioButton = new RadioButton(this);
radioButton.setText(s);
radioButton.setOnClickListener(new RadioButtonOnClickListener());
radioGroup.addView(radioButton);
@@ -496,7 +496,7 @@ public class FavoriteActivity extends Activity {
}
BW.write(s);
BW.flush();
Toast.makeText(FavoriteActivity.this, "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(Thread.currentThread().getStackTrace()[2] + "", e.toString());
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();