收藏夹分类单选改成下拉列表
This commit is contained in:
parent
9361ad849d
commit
6c46f679ff
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hty.browser"
|
||||
android:versionCode="4"
|
||||
android:versionName="4.32">
|
||||
android:versionName="4.33">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 查询网络状态权限 -->
|
||||
|
|
|
@ -9,7 +9,7 @@ p { text-indent:2em; }
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.32</h2>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.33</h2>
|
||||
<p>内置扩展的浏览器。</p>
|
||||
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
|
||||
<p>作者:海天鹰</p>
|
||||
|
@ -23,6 +23,7 @@ p { text-indent:2em; }
|
|||
<p><a href="https://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon" target="_blank">获取网页图标</a></p>
|
||||
<p><a href="https://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
|
||||
<h3>更新日志:</h3>
|
||||
<h3>V4.33 (2024-01-19)</h3><ol><li>收藏夹分类:使用下拉列表代替单选组。</li></ol>
|
||||
<h3>V4.32 (2023-11-19)</h3><ol><li>增加GIF屏蔽。</li><li>在Activity中处理广告屏蔽规则。</li></ol>
|
||||
<h3>V4.31 (2023-04-17)</h3><ol><li>取消自动升级,以免因升级错误引起崩溃。</li></ol>
|
||||
<h3>V4.30 (2023-03-23)</h3><ol><li>收藏夹测试 ExpandableListView 控件</li></ol>
|
||||
|
|
|
@ -41,6 +41,8 @@ import android.widget.Spinner;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
@ -50,10 +52,10 @@ import java.util.ArrayList;
|
|||
public class FavoriteActivity extends Activity {
|
||||
EditText editText;
|
||||
ImageButton imageButton_clear;
|
||||
RadioGroup radioGroup;
|
||||
InputMethodManager IMM;
|
||||
ListView listView;
|
||||
SimpleCursorAdapter adapter;
|
||||
Spinner spinner;
|
||||
int position = 0;
|
||||
|
||||
@Override
|
||||
|
@ -67,12 +69,23 @@ public class FavoriteActivity extends Activity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
editText.setText("");
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
imageButton_clear.setVisibility(View.GONE);
|
||||
editText = (EditText) findViewById(R.id.editText);
|
||||
editText.addTextChangedListener(new EditChangedListener());
|
||||
radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
|
||||
spinner = (Spinner) findViewById(R.id.spinner);
|
||||
spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", "spinner: " + arg2);
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
String s = arg0.getItemAtPosition(arg2).toString();
|
||||
search(1, s);
|
||||
}
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
}
|
||||
});
|
||||
genCategory();
|
||||
|
||||
listView = (ListView) findViewById(R.id.listView1);
|
||||
|
@ -110,9 +123,6 @@ public class FavoriteActivity extends Activity {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,8 +156,6 @@ public class FavoriteActivity extends Activity {
|
|||
helper.insert("category", values);
|
||||
IMM.hideSoftInputFromWindow(editText1.getWindowToken(), 0);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "分类已存在", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -159,10 +167,7 @@ public class FavoriteActivity extends Activity {
|
|||
case 1:
|
||||
builder = new AlertDialog.Builder(FavoriteActivity.this);
|
||||
builder.setIcon(android.R.drawable.ic_menu_edit);
|
||||
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
|
||||
if (radioButton == null)
|
||||
break;
|
||||
final String title = radioButton.getText().toString();
|
||||
final String title = spinner.getSelectedItem().toString();
|
||||
if (title.equals(""))
|
||||
break;
|
||||
builder.setTitle(title);
|
||||
|
@ -181,8 +186,6 @@ public class FavoriteActivity extends Activity {
|
|||
db.update("category", values, "category = '" + title + "'", null);
|
||||
db.update(helper.TableName, values, "category = '" + title + "'", null);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
IMM.hideSoftInputFromWindow(editText_rename.getWindowToken(), 0);
|
||||
}
|
||||
});
|
||||
|
@ -196,8 +199,6 @@ public class FavoriteActivity extends Activity {
|
|||
values.put("category", "");
|
||||
db.update(helper.TableName, values, "category = '" + title + "'", null);
|
||||
genCategory();
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("取消", null);
|
||||
|
@ -334,11 +335,11 @@ public class FavoriteActivity extends Activity {
|
|||
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)
|
||||
String s = spinner.getSelectedItem().toString();
|
||||
if (s.equals(""))
|
||||
search(0, editText.getText().toString());
|
||||
else
|
||||
search(1, radioButton.getText().toString());
|
||||
search(1, s);
|
||||
try { //关闭
|
||||
field.set(dialog, true);
|
||||
dialog.dismiss();
|
||||
|
@ -396,16 +397,6 @@ public class FavoriteActivity extends Activity {
|
|||
return true;
|
||||
}
|
||||
|
||||
class RadioButtonOnClickListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
RadioButton radioButton = (RadioButton) v;
|
||||
String s = radioButton.getText().toString();
|
||||
search(1, s);
|
||||
}
|
||||
}
|
||||
|
||||
void search(int type, String s) {
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor1 = null;
|
||||
|
@ -445,17 +436,16 @@ public class FavoriteActivity extends Activity {
|
|||
|
||||
void genCategory() {
|
||||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
radioGroup.removeAllViews();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String s = cursor.getString(cursor.getColumnIndex("category"));
|
||||
RadioButton radioButton = new RadioButton(this);
|
||||
radioButton.setText(s);
|
||||
radioButton.setOnClickListener(new RadioButtonOnClickListener());
|
||||
radioGroup.addView(radioButton);
|
||||
list.add(s);
|
||||
}
|
||||
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, list);
|
||||
spinner.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,7 +466,6 @@ public class FavoriteActivity extends Activity {
|
|||
imageButton_clear.setVisibility(View.VISIBLE);
|
||||
}
|
||||
search(0, s.toString());
|
||||
radioGroup.clearCheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#888" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
|
@ -33,24 +37,11 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="#ffffff"
|
||||
android:paddingLeft="-15dp"
|
||||
android:paddingRight="-15dp"
|
||||
android:paddingLeft="-5dp"
|
||||
android:paddingRight="-5dp"
|
||||
android:src="@android:drawable/ic_menu_close_clear_cancel" />
|
||||
</LinearLayout>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroup"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listView1"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
Loading…
Reference in New Issue