与此处的其他几篇文章一样,我正在尝试创建一个ListView,其中包含每行的CheckBox,并使用sqlite数据库存储选择的当前状态.

从http://appfulcrum.com/?p=351的示例开始,这个示例并不完全正常,我创建了一个创建数据库的简单应用程序,用20个项目填充它,并显示列表.

它成功检索状态并存储选择的状态.

但是,如果我更改它,它无法正确显示CheckBox状态,滚动到列表的另一端,然后向后滚动.例如如果我选择第一个CheckBox,滚动到底部,然后回到顶部,不再设置CheckBox.这是在Android 2.1三星手机上运行.

如果我返回主屏幕,返回列表,CheckBox已正确设置,因此数据库确实已更新.

该示例扩展了SimpleCursorAdapter,并且getView()根据表中选择列的值,根据需要使用true或false调用setChecked().

以下是所有来源.

我当然很感激被告知,“呃,这是你的问题……”

CustomListViewDB.java

// src/CustomListViewDB.java
package com.appfulcrum.blog.examples.listviewcustomdb;

import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class CustomListViewDB extends ListActivity {

    private ListView mainListView = null;
    CustomsqlCursorAdapter adapter = null;
    private sqlHelper dbHelper = null;
    private Cursor currentCursor = null;

    private ListView listView = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple);

        if (this.dbHelper == null) {
            this.dbHelper = new sqlHelper(this);

        }

        listView = getListView();
        listView.setItemsCanFocus(false);
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        //listView.setClickable(true);

        Button btnClear = (Button) findViewById(R.id.btnClear);
        btnClear.setonClickListener(new OnClickListener() {

            public void onClick(View v) {
                Toast.makeText(getApplicationContext()," You clicked Clear button",Toast.LENGTH_SHORT).show();
                ClearDBSelections();
            }
        });

        new SelectDataTask().execute();

        this.mainListView = getListView();

        mainListView.setCacheColorHint(0);

    }

    @Override
    protected void onRestart() {
        super.onRestart();
        new SelectDataTask().execute();
    }

    @Override
    protected void onPause() {

        super.onPause();
        this.dbHelper.close();
    }

    protected void ClearDBSelections() {

        this.adapter.ClearSelections();

    }

    private class SelectDataTask extends AsyncTask<Void,Void,String> {

        protected String doInBackground(Void... params) {

            try {

                CustomListViewDB.this.dbHelper.createDatabase(dbHelper.dbsqlite);
                CustomListViewDB.this.dbHelper.openDataBase();

                CustomListViewDB.this.currentCursor = CustomListViewDB.this.dbHelper
                        .getCursor();

            } catch (sqlException sqle) {

                throw sqle;

            }
            return null;
        }

        // can use UI thread here
        protected void onPostExecute(final String result) {

            startManagingCursor(CustomListViewDB.this.currentCursor);
            int[] listFields = new int[] { R.id.txtTitle };
            String[] dbColumns = new String[] { sqlHelper.COLUMN_TITLE };

            CustomListViewDB.this.adapter = new CustomsqlCursorAdapter(
                    CustomListViewDB.this,R.layout.single_item,CustomListViewDB.this.currentCursor,dbColumns,listFields,CustomListViewDB.this.dbHelper);
            setlistadapter(CustomListViewDB.this.adapter);

        }
    }

}

CustomsqlCursorAdapter.java

// src/CustomsqlCursorAdapter.java

package com.appfulcrum.blog.examples.listviewcustomdb;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlException;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedchangelistener;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class CustomsqlCursorAdapter extends SimpleCursorAdapter {
    private Context mContext;

    private sqlHelper mDbHelper;
    private Cursor mCurrentCursor;

    public CustomsqlCursorAdapter(Context context,int layout,Cursor c,String[] from,int[] to,sqlHelper dbHelper) {
        super(context,layout,c,from,to);
        this.mCurrentCursor = c;
        this.mContext = context;
        this.mDbHelper = dbHelper;

    }

    public View getView(int pos,View inView,ViewGroup parent) {
        View v = inView;
        if (v == null) {
            LayoutInflater inflater = (LayoutInflater) mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = inflater.inflate(R.layout.single_item,null);
        }

        if (!this.mCurrentCursor.movetoPosition(pos)) {
            throw new sqlException("CustomsqlCursorAdapter.getView: Unable to move to position: "+pos);
        }

        CheckBox cBox = (CheckBox) v.findViewById(R.id.bcheck);

        // save the row's _id value in the checkBox's tag for retrieval later
        cBox.setTag(Integer.valueOf(this.mCurrentCursor.getInt(0)));

        if (this.mCurrentCursor.getInt(sqlHelper.COLUMN_SELECTED_idx) != 0) {
            cBox.setChecked(true);
            Log.w("sqlHelper","CheckBox true for pos "+pos+",id="+this.mCurrentCursor.getInt(0));
        } else {
            cBox.setChecked(false);
            Log.w("sqlHelper","CheckBox false for pos "+pos+",id="+this.mCurrentCursor.getInt(0));
        }
        //cBox.setonClickListener(this);
        cBox.setonCheckedchangelistener(new OnCheckedchangelistener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {

                Log.w("sqlHelper","Selected a CheckBox and in onCheckedChanged: "+isChecked);

                Integer _id = (Integer) buttonView.getTag();
                ContentValues values = new ContentValues();
                values.put(sqlHelper.COLUMN_SELECTED,isChecked ? Integer.valueOf(1) : Integer.valueOf(0));
                mDbHelper.dbsqlite.beginTransaction();
                try {
                    if (mDbHelper.dbsqlite.update(sqlHelper.TABLE_NAME,values,"_id=?",new String[] { Integer.toString(_id) }) != 1) {
                        throw new sqlException("onCheckedChanged Failed to update _id="+_id);
                    }
                    mDbHelper.dbsqlite.setTransactionSuccessful();
                } finally {
                    mDbHelper.dbsqlite.endTransaction();
                }

                Log.w("sqlHelper","-- _id="+_id+",isChecked="+isChecked);
            }
        });

        TextView txtTitle = (TextView) v.findViewById(R.id.txtTitle);
        txtTitle.setText(this.mCurrentCursor.getString(this.mCurrentCursor
                .getColumnIndex(sqlHelper.COLUMN_TITLE)));

        return (v);
    }

    public void ClearSelections() {
        this.mDbHelper.clearSelections();
        this.mCurrentCursor.requery();

    }
}

ListViewWithDBActivity.java

package com.appfulcrum.blog.examples.listviewcustomdb;

import android.app.Activity;
import android.os.Bundle;

public class ListViewWithDBActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

提供sqlHelper

// sqlHelper.java

package com.appfulcrum.blog.examples.listviewcustomdb;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlException;
import android.database.sqlite.sqliteDatabase;
import android.database.sqlite.sqliteOpenHelper;
import android.database.sqlite.sqliteQueryBuilder;
import android.database.sqlite.sqliteStatement;
import android.util.Log;

public class sqlHelper extends sqliteOpenHelper {
    private static final String DATABASE_PATH = "/data/data/com.appfulcrum.blog.examples.listviewcustomdb/databases/";

    public static final String DATABASE_NAME = "TodoList";

    public static final String TABLE_NAME = "TodoItems";
    public static final int TodoItems_VERSION = 1;

    public static final String COLUMN_ID = "_id";               // 0
    public static final String COLUMN_TITLE = "title";          // 1
    public static final String COLUMN_NAME_DESC = "description";// 2
    public static final String COLUMN_SELECTED = "selected";    // 3
    public static final int    COLUMN_SELECTED_idx = 3;

    public sqliteDatabase dbsqlite;
    private Context mContext;

    public sqlHelper(Context context) {
        super(context,DATABASE_NAME,null,1);
        mContext = context;
    }

    @Override
    public void onCreate(sqliteDatabase db) {
        createDB(db);
    }

    @Override
    public void onUpgrade(sqliteDatabase db,int oldVersion,int newVersion) {
        Log.w("sqlHelper","Upgrading database from version " + oldVersion
                + " to " + newVersion + ",which will destroy all old data");

        db.execsql("DROP TABLE IF EXISTS TodoItems;");

        createDB(db);
    }

    public void createDatabase(sqliteDatabase db) {
        createDB(db);
    }

    private void createDB(sqliteDatabase db) {
        if (db == null) {
            db = mContext.openorCreateDatabase(DATABASE_NAME,null);
        }

        db.execsql("CREATE TABLE IF NOT EXISTS TodoItems (_id INTEGER PRIMARY KEY,title TEXT,"
                +" description TEXT,selected INTEGER);");
        db.setVersion(TodoItems_VERSION);

        //
        // Generate a few rows for an example
        //
        // find out how many rows already exist,and make sure there's some minimum
        sqliteStatement s = db.compileStatement("select count(*) from TodoItems;");

        long count = s.simpleQueryForLong();
        for (int i = 0; i < 20-count; i++) {
            db.execsql("INSERT INTO TodoItems VALUES(NULL,'Task #"+i+"','Description #"+i+"',0);");
        }
    }

    public void openDataBase() throws sqlException {
        String myPath = DATABASE_PATH + DATABASE_NAME;

        dbsqlite = sqliteDatabase.openDatabase(myPath,sqliteDatabase.OPEN_READWRITE);
    }

    @Override
    public synchronized void close() {
        if (dbsqlite != null)
            dbsqlite.close();

        super.close();
    }

    public Cursor getCursor() {
        sqliteQueryBuilder queryBuilder = new sqliteQueryBuilder();

        queryBuilder.setTables(TABLE_NAME);

        String[] asColumnsToReturn = new String[] { COLUMN_ID,COLUMN_TITLE,COLUMN_NAME_DESC,COLUMN_SELECTED };

        Cursor mCursor = queryBuilder.query(dbsqlite,asColumnsToReturn,COLUMN_ID+" ASC");

        return mCursor;
    }

    public void clearSelections() {
        ContentValues values = new ContentValues();
        values.put(COLUMN_SELECTED,0);
        this.dbsqlite.update(sqlHelper.TABLE_NAME,null);
    }
}

Start.java

//src/Start.java
package com.appfulcrum.blog.examples.listviewcustomdb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class Start extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btnSimple = (Button) findViewById(R.id.btnSimple);
        btnSimple.setonClickListener(new OnClickListener() {

            public void onClick(View v) {

                Toast.makeText(getApplicationContext()," You clicked ListView From DB button",Toast.LENGTH_SHORT).show();

                Intent intent = new Intent(v.getContext(),CustomListViewDB.class);
                startActivityForResult(intent,0);
            }
        });

    }
}

布局/ main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/buttonlayout" android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:gravity="left|top" android:paddingTop="2dp"
    android:paddingBottom="2dp">

    <TextView android:id="@+id/txtTest" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:textStyle="bold"
        android:text="@string/app_name" android:textSize="15sp"
        android:textColor="#FF0000" android:gravity="center_vertical"
        android:paddingLeft="5dp">
    </TextView>

    <Button android:id="@+id/btnSimple" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:textSize="15sp"
        android:text="Listview from DB"
        android:textColor="#000000"
        >
    </Button>

</LinearLayout>

布局/ simple.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout android:id="@+id/buttonlayout"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:height="32dp"
        android:gravity="left|top" android:paddingTop="2dp"
        android:paddingBottom="2dp">

        <LinearLayout android:id="@+id/buttonlayout2"
            android:orientation="horizontal" android:layout_height="wrap_content"
            android:gravity="left|center_vertical" android:layout_width="wrap_content"
            android:layout_gravity="left|center_vertical">

            <TextView android:id="@+id/txtTest"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:textStyle="bold"
                android:text="@string/list_header" android:textSize="15sp"
                android:gravity="center_vertical" android:paddingLeft="5dp">
            </TextView>

            <Button android:id="@+id/btnClear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Clear"
                android:textSize="15sp" android:layout_marginLeft="10px"
                android:layout_marginRight="10px"
                android:layout_marginBottom="2px"
                android:layout_marginTop="2px" android:height="15dp"
                android:width="70dp"></Button>
        </LinearLayout>
    </LinearLayout>

    <TableLayout android:id="@+id/TableLayout01"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:stretchColumns="*">
        <TableRow>
            <ListView android:id="@android:id/list"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ListView>
        </TableRow>

    </TableLayout>

</LinearLayout>

布局/ single_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="horizontal" android:gravity="center_vertical">

    <CheckBox android:id="@+id/bcheck"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent" />

        <TextView android:id="@+id/txtTitle"
            android:layout_width="wrap_content" android:gravity="left|center_vertical"
            android:layout_height="?android:attr/listPreferredItemHeight"
            android:layout_alignParentLeft="true" 
            android:textSize="20sp" android:text="Test"
            android:textStyle="bold" android:paddingLeft="5dp"
            android:paddingRight="2dp" android:focusable="false"
            android:focusableInTouchMode="false"></TextView>
        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="horizontal"
            android:gravity="right|center_vertical">
        </LinearLayout>

</LinearLayout>

值/ strings.xml中

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World,ListViewWithDBActivity!</string>
    <string name="app_name">ListViewWithDB</string>
    <string name="list_header">List Headers</string>
</resources>

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1" android:versionName="1.0"    
    package="com.appfulcrum.blog.examples.listviewcustomdb">

    <application android:icon="@drawable/icon"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.NoTitleBar">
        >
        <activity android:name=".Start" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".CustomListViewDB"></activity>
    </application>

    <uses-sdk android:minSdkVersion="7" /> <!-- android 1.6 -->
</manifest>

如果你想构建,将一些任意的icon.png扔进drawable.

提前致谢.

解决方法

我发现异地问题最完整的解决方案.

在Android ListView with CheckBox : Retain State

感谢帮助人员.

Android:带有CheckBox的ListView,从SQLite数据库填充不太正常的更多相关文章

  1. HTML5 WebSocket实现点对点聊天的示例代码

    这篇文章主要介绍了HTML5 WebSocket实现点对点聊天的示例代码的相关资料,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  2. ios – 在Swift的UIView中找到UILabel

    我正在尝试在我的UIViewControllers的超级视图中找到我的UILabels.这是我的代码:这是在Objective-C中推荐的方式,但是在Swift中我只得到UIViews和CALayer.我肯定在提供给这个方法的视图中有UILabel.我错过了什么?我的UIViewController中的调用:解决方法使用函数式编程概念可以更轻松地实现这一目标.

  3. ios – 在Swift中将输入字段字符串转换为Int

    所以我非常擅长制作APP广告Swift,我试图在文本字段中做一些非常简单的输入,取值,然后将它们用作Int进行某些计算.但是’vardistance’有些东西不正确它是导致错误的最后一行代码.它说致命错误:无法解开Optional.None解决方法在你的例子中,距离是一个Int?否则称为可选的Int..toInt()返回Int?因为从String到Int的转换可能失败.请参阅以下示例:

  4. 如何在iOS中检测文本(字符串)语言?

    例如,给定以下字符串:我想检测每个声明的字符串中使用的语言.让我们假设已实现函数的签名是:如果没有检测到语言,则返回可选字符串.因此,适当的结果将是:有一个简单的方法来实现它吗?

  5. PhoneGap / iOS上的SQLite数据库 – 超过5mb可能

    我误解了什么吗?Phonegap中的sqlitedbs真的有5mb的限制吗?我正在使用Phonegap1.2和iOS5.解决方法您可以使用带有phonegap插件的原生sqliteDB,您将没有任何限制.在iOS5.1中,Websql被认为是可以随时删除的临时数据…

  6. xamarin – 崩溃在AccountStore.Create().保存(e.Account,“);

    在Xamarin.Forms示例TodoAwsAuth中https://developer.xamarin.com/guides/xamarin-forms/web-services/authentication/oauth/成功登录后,在aOnAuthenticationCompleted事件中,应用程序在尝试保存到Xamarin.Auth时崩溃错误说不能对钥匙串说期待着寻求帮助.解决方法看看你

  7. ios – 将视频分享到Facebook

    我正在编写一个简单的测试应用程序,用于将视频从iOS上传到Facebook.由于FacebookSDK的所有文档都在Objective-C中,因此我发现很难在线找到有关如何使用Swift执行此操作的示例/教程.到目前为止我有这个在我的UI上放置一个共享按钮,但它看起来已禁用,从我读到的这是因为没有内容设置,但我看不出这是怎么可能的.我的getVideoURL()函数返回一个NSURL,它肯定包含视

  8. xcode – 错误“线程1:断点2.1”

    我正在研究RESTAPI管理器.这是一个错误,我无法解决它.我得到的错误在下面突出显示.当我打电话给这个班级获取资源时:我评论的线打印:Thread1:breakpoint2.1我需要修复错误的建议.任何建议都非常感谢解决方法您可能在不注意的情况下意外设置了断点.单击并拖动代表断路器外部断点的蓝色刻度线以将其擦除.

  9. ios – 更改导航栏标题swift中的字符间距

    类型的值有人可以帮我这个或建议一种不同的方式来改变swift中导航栏标题中的字符间距吗?解决方法您无法直接设置属性字符串.你可以通过替换titleView来做一个技巧

  10. ios – 备份.sqlite(核心数据)

    我有一个基于核心数据的应用程序,它使用DropBox备份和恢复数据.我备份的方式非常简单.我复制用户的保管箱上的.sqlite文件.现在我的备份和恢复功能正常.问题出在.sqlite文件本身.看来.sqlite文件不完整.我在我的应用程序中输入了大约125个条目并进行了备份.备份出现在我的DropBox中但是当我使用.sqlite资源管理器工具查看内容时,我只看到第117个记录的记录.我尝试更新第

随机推荐

  1. bluetooth-lowenergy – Altbeacon库无法在Android 5.0上运行

    昨天我在Nexus4上获得了Android5.0的更新,并且altbeacon库停止了检测信标.似乎在监视和测距时,didEnterRegion和didRangeBeaconsInRegion都没有被调用.即使RadiusNetworks的Locate应用程序现在表现不同,一旦检测到信标的值,它们就不再得到更新,并且通常看起来好像信标超出了范围.我注意到的一点是,现在在logcat中出现以下行“B

  2. android – react-native动态更改响应者

    我正在使用react-native进行Android开发.我有一个视图,如果用户长按,我想显示一个可以拖动的动画视图.我可以使用PanResponder实现这一点,它工作正常.但我想要做的是当用户长按时,用户应该能够继续相同的触摸/按下并拖动新显示的Animated.View.如果您熟悉Google云端硬盘应用,则它具有类似的功能.当用户长按列表中的任何项目时,它会显示可拖动的项目.用户可以直接拖

  3. android – 是否有可能通过使用与最初使用的证书不同的证书对其进行签名来发布更新的应用程序

    是否可以通过使用与最初使用的证书不同的证书进行签名来发布Android应用程序的更新?我知道当我们尝试将这样的构建上传到市场时,它通常会给出错误消息.但有没有任何出路,比如将其标记为主要版本,指定市场中的某个地方?解决方法不,你不能这样做.证书是一种工具,可确保您是首次上传应用程序的人.所以总是备份密钥库!

  4. 如何检测Android中是否存在麦克风?

    ..所以我想在让用户访问语音输入功能之前检测麦克风是否存在.如何检测设备上是否有麦克风.谢谢.解决方法AndroidAPI参考:hasSystemFeature

  5. Android – 调用GONE然后VISIBLE使视图显示在错误的位置

    我有两个视图,A和B,视图A在视图B上方.当我以编程方式将视图A设置为GONE时,它将消失,并且它正下方的视图将转到视图A的位置.但是,当我再次将相同的视图设置为VISIBLE时,它会在视图B上显示.我不希望这样.我希望视图B回到原来的位置,这是我认为会发生的事情.我怎样才能做到这一点?编辑–代码}这里是XML:解决方法您可以尝试将两个视图放在RelativeLayout中并相对于彼此设置它们的位置.

  6. android – 获得一首歌的流派

    我如何阅读与歌曲相关的流派?我可以读这首歌,但是如何抓住这首歌的流派,它存放在哪里?解决方法检查此代码:

  7. android – 使用textShadow折叠工具栏

    我有一个折叠工具栏的问题,在展开状态我想在文本下面有一个模糊的阴影,我使用这段代码:用:我可以更改textColor,它可以工作,但阴影不起作用.我为阴影尝试了很多不同的值.是否可以为折叠文本投射阴影?

  8. android – 重用arm共享库

    我已经建立了armarm共享库.我有兴趣重用一个函数.我想调用该函数并获得返回值.有可能做这样的事吗?我没有任何头文件.我试过这个Android.mk,我把libtest.so放在/jni和/libs/armeabi,/lib/armeabi中.此时我的cpp文件编译,但现在是什么?我从objdump知道它的名字编辑:我试图用这个android.mk从hello-jni示例中添加prebuild库:它工作,但libtest.so相同的代码显示以下错误(启动时)libtest.so存在于libhello-j

  9. android – 为NumberPicker捕获键盘’Done’

    我有一个AlertDialog只有一些文本,一个NumberPicker,一个OK和一个取消.(我知道,这个对话框还没有做它应该保留暂停和恢复状态的事情.)我想在软键盘或其他IME上执行“完成”操作来关闭对话框,就像按下了“OK”一样,因为只有一个小部件可以编辑.看起来处理IME“Done”的最佳方法通常是在TextView上使用setonEditorActionListener.但我没有任何Te

  10. android – 想要在调用WebChromeClient#onCreateWindow时知道目标URL

    当我点击一个带有target=“_blank”属性的超链接时,会调用WebChromeClient#onCreateWindow,但我找不到新的窗口将打开的新方法?主页url是我唯一能知道的东西?我想根据目标网址更改应用行为.任何帮助表示赞赏,谢谢!

返回
顶部