新建收藏增加分类,修改导出HTML
This commit is contained in:
@@ -107,7 +107,6 @@ public class FavoriteActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
//search(0, "");
|
||||
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
|
||||
radioButton.performClick();
|
||||
}
|
||||
@@ -136,8 +135,8 @@ public class FavoriteActivity extends Activity {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String s = editText1.getText().toString();
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
Cursor c = helper.category(s);
|
||||
if (c.getCount() == 0) {
|
||||
Cursor cursor = helper.category(s);
|
||||
if (cursor.getCount() == 0) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", s);
|
||||
helper.insert("category", values);
|
||||
@@ -164,23 +163,31 @@ public class FavoriteActivity extends Activity {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
String s = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n<title>收藏夹</title>\n<style>a { text-decoration:none; }\ntable { table-layout:fixed; width:100%; border-collapse:collapse; }\nth, td { border:1px solid black; padding:5px; overflow:hidden; text-overflow: ellipsis; }\n</style>\n</head>\n<body>\n<h2 align=center>收藏夹" + adapter.getCount() + "</h2>\n<table>\n<tr><th>标题</th><th>网址</th></tr>\n";
|
||||
for (int i=0; i<adapter.getCount(); i++){
|
||||
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
||||
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
||||
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
||||
s = s + "<tr><td>" + textView_title.getText().toString() + "</td><td><a href=\"" + textView_website.getText().toString() + "\" target=\"_blank\">" + textView_website.getText().toString() + "</a></td></tr>\n";
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
Cursor cursor = helper.query("");
|
||||
String s = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n<title>收藏夹</title>\n<style>\na { text-decoration: none; }\ntable { table-layout: fixed; width: 100%; border-collapse: collapse; }\nth, td { border: 1px solid black; padding: 5px; overflow: hidden; text-overflow: ellipsis; }\ntd:nth-child(3) { white-space: nowrap; }\n</style>\n</head>\n<body>\n<h2 align=center>收藏夹" + cursor.getCount() + "</h2>\n<table>\n<tr><th>标题</th><th>网址</th><th>分类</th></tr>\n";
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String website = cursor.getString(cursor.getColumnIndex("website"));
|
||||
String category = cursor.getString(cursor.getColumnIndex("category"));
|
||||
s = s + "<tr><td>" + title + "</td><td><a href=\"" + website + "\" target=\"_blank\">" + website + "</a></td><td>" + category + "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
s += "</table>\n</body>\n</html>";
|
||||
writeFile("webfav.htm", s);
|
||||
break;
|
||||
case 3:
|
||||
s = "";
|
||||
for (int i=0; i<adapter.getCount(); i++){
|
||||
LinearLayout layout = (LinearLayout) listView.getAdapter().getView(i, null, null);
|
||||
TextView textView_title = (TextView) layout.findViewById(R.id.title);
|
||||
TextView textView_website = (TextView) layout.findViewById(R.id.website);
|
||||
s = s + textView_title.getText().toString().replace(",", ",") + "," + textView_website.getText().toString() + "\n";
|
||||
helper = new DBHelper(getApplicationContext());
|
||||
cursor = helper.query("");
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
String website = cursor.getString(cursor.getColumnIndex("website"));
|
||||
String category = cursor.getString(cursor.getColumnIndex("category"));
|
||||
s = s + title.replace(",", ",") + "," + website + "," + category + "\n";
|
||||
}
|
||||
}
|
||||
writeFile("webfav.csv", s);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user