GVKun编程网logo

React Table toggleRowExpanded 不起作用(react-table)

7

对于想了解ReactTabletoggleRowExpanded不起作用的读者,本文将是一篇不可错过的文章,我们将详细介绍react-table,并且为您提供关于AndroidExpandableLi

对于想了解React Table toggleRowExpanded 不起作用的读者,本文将是一篇不可错过的文章,我们将详细介绍react-table,并且为您提供关于Android ExpandableListActivity和SimpleCursorTreeAdapter?、Android M – GoogleAccountCredential setSelectedAccount不起作用 – 名称不能为null、android – clearAllTables不起作用、android – 使用TextInputLayouts passwordToggleEnabled的可见密码的有价值信息。

本文目录一览:

React Table toggleRowExpanded 不起作用(react-table)

React Table toggleRowExpanded 不起作用(react-table)

在 react-table 文档中,toggleRowExpanded 是一个用于切换 'a' 行是否展开的函数。 toggleRowExpanded 需要一个 single rowId 而不是一个 id 数组和一个可选的 isExpanded 布尔值,它是该单行的状态。

在共享的代码和框示例中,要注意 2 处更改:

  1. rowId 不是数据中的 id - 而是表中行的 id - 在这种情况下将成为索引
  2. toggleRowExpanded 函数将针对每一行单独调用。

为了让示例工作,

   data.forEach((val,index) => {
          toggleRowExpanded(index,isEven ? index%2 === 0 : false);
        })

Android ExpandableListActivity和SimpleCursorTreeAdapter?

Android ExpandableListActivity和SimpleCursorTreeAdapter?

我正在为 Android编写一个简单的应用程序.

我有2个表 – 一个叫做“grous”,另一个叫做“group_items”.

我想使用可扩展列表来显示两个表中的数据.

最好的方法是什么?是否可以使用SimpleCursorTreeAdapter映射数据?我找不到任何有用的例子.

我看到示例使用ArrayAdapter创建可扩展列表,所以我应该先将数据转换为数组,然后创建一个可扩展列表,还是直接执行?

我不需要一个完整的工作示例 – 只是一个建议,什么是正确和最有效的方式来做到这一点.

Leonti

解决方法

我发现最简单的解决方案是使用SimpleCursorTreeAdapter.
这里是代码示例(重要部分):
public class ExercisesList extends ExpandableListActivity {


private ExcercisesDbAdapter mDbHelper; // your db adapter
private Cursor mGroupsCursor; // cursor for list of groups (list top nodes)
private int mGroupIdColumnIndex;
private Myexpandablelistadapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mDbHelper = new ExcercisesDbAdapter(this);
        mDbHelper.open();
        fillData();
}

private void fillData() {
        mGroupsCursor = mDbHelper.fetchAllGroups(); // fills cursor with list of your top nodes - groups 
        startManagingCursor(mGroupsCursor);

        // Cache the ID column index
        mGroupIdColumnIndex = mGroupsCursor
                        .getColumnIndexOrThrow(ExcercisesDbAdapter.KEY_ROWID);

        // Set up our adapter
        mAdapter = new Myexpandablelistadapter(mGroupsCursor,this,android.R.layout.simple_expandable_list_item_1,R.layout.exercise_list_row,new String[] { ExcercisesDbAdapter.KEY_TITLE },// group title for group layouts
                        new int[] { android.R.id.text1 },// exercise title for child layouts
                        new int[] { R.id.exercise_title });

        setlistadapter(mAdapter);
}

// extending SimpleCursorTreeAdapter
public class Myexpandablelistadapter extends SimpleCursorTreeAdapter {

        public Myexpandablelistadapter(Cursor cursor,Context context,int groupLayout,int childLayout,String[] groupFrom,int[] groupTo,String[] childrenFrom,int[] childrenTo) {
                super(context,cursor,groupLayout,groupFrom,groupTo,childLayout,childrenFrom,childrenTo);
        }

        // returns cursor with subitems for given group cursor
        @Override
        protected Cursor getChildrenCursor(Cursor groupCursor) {
                Cursor exercisesCursor = mDbHelper
                                .fetchExcercisesForGroup(groupCursor
                                                .getLong(mGroupIdColumnIndex));
                startManagingCursor(exercisesCursor);
                return exercisesCursor;
        }

        // I needed to process click on click of the button on child item
        public View getChildView(final int groupPosition,final int childPosition,boolean isLastChild,View convertView,ViewGroup parent) {
                View rowView = super.getChildView(groupPosition,childPosition,isLastChild,convertView,parent);

                Button details = (Button) rowView.findViewById(R.id.view_button);

                details.setonClickListener(new OnClickListener() {
                        public void onClick(View v) {

                                Cursor exerciseCursor = getChild(groupPosition,childPosition);

                                Long exerciseId = exerciseCursor.getLong(exerciseCursor.getColumnIndex(ExcercisesDbAdapter.KEY_ROWID));

                                Intent i = new Intent(ExercisesList.this,ExerciseView.class);
                                i.putExtra(ExcercisesDbAdapter.KEY_ROWID,exerciseId);
                                startActivity(i);
                        }
                });

                return rowView;
        }

}

}

希望会有用的;)

Android M – GoogleAccountCredential setSelectedAccount不起作用 – 名称不能为null

Android M – GoogleAccountCredential setSelectedAccount不起作用 – 名称不能为null

在Android M-Preview上,GoogleAccountCredential.setSelectedAccount似乎不起作用.

调试时,我注意到在调用该方法后,该对象的selectedAccount和accountName字段仍然为null.

在调试时,您可以看到我的变量accountName不为空或null,我调用.setSelectedAccountName(),但正如您在调试窗口中看到的那样,GoogleAccountCredential中的字段仍为空.

Debugging window code


Debugging window debug values

我认为这可能与某些权限有关?在我的清单上,我声明了以下权限:

我知道你在M上免费获得GET_ACCOUNTS许可(根据https://developer.android.com/preview/features/runtime-permissions.html#normal),但M-Preview的其他两个权限是“未知”.也许吧,那就是那个?

最佳答案
android.permission.GET_ACCOUNTS有protectionLevel:dangerous,现在是Contacts权限组的一部分,这意味着你应该在运行时使用新的Activity.requestPermissions()来请求它.

只有这样,您才能与设备上其他应用创建的帐户进行互动.

android – clearAllTables不起作用

android – clearAllTables不起作用

Android Room有方法void clearallTables(),根据文档,它做了以下内容:

Deletes all rows from all the tables that are registered to this database as entities().

This does NOT reset the auto-increment value generated by autoGenerate().

After deleting the rows, Room will set a WAL checkpoint and run VACUUM. This means that the data is completely erased. The space will be reclaimed by the system if the amount surpasses the threshold of database file size.

我在我的项目中检查了它,看起来db在该调用之后没有数据,但是当我拉动时
 来自我的设备的* .db文件并在sqlite查看器中打开它我已经看到所有数据都存在,表格已填满且没有任何内容被删除.
怎么可能?我认为这是我的应用程序中的潜在缺陷.请提供清洁室数据库的可靠方法

解决方法:

looks like db has no data after that call

这意味着该方法有效.

when I pulled *.db file from my device and opened it in sqlite viewer
I’ve seen that all the data exists

很可能事务还没有从WAL文件移动到原始数据库.

您可以使用wal_checkpoint pragma强制检查点.根据数据库查询以下语句.

pragma wal_checkpoint(full)

android – 使用TextInputLayouts passwordToggleEnabled的可见密码

android – 使用TextInputLayouts passwordToggleEnabled的可见密码

我正在使用TextInputLayout和支持库中的新函数:passwordToggleEnabled.这给了一个很好的“眼睛” – 图标,让用户可以打开和关闭密码可见性.

我的问题是,是否有办法使用此功能,但开始密码可见?

我的xml:

<android.support.design.widget.TextInputLayout
                    android:id="@+id/password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:passwordToggleEnabled="true">

                    <EditText
                        android:id="@+id/password_edit"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/prompt_password"
                        android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>

切换看起来与此类似:

我还没有找到一种方法在xml中执行此操作,而不是在呈现视图后手动切换可见性的方法.如果我将EditText的输入类型设置为textVisiblePassword,则不会显示切换.如果我在代码中使用例如mPasswordEditText.setTransformationMethod(null);显示密码但切换消失,用户无法再次隐藏密码.我知道我可以手动完成所有操作,但只是想知道我是否可以使用新的魔术切换工作

解决方法

其中一种方法是,我们可以从TextInputLayout中搜索CheckableImageButton,然后根据EditText的密码可见性状态以编程方式对其执行onClick.

这是代码片段.

private CheckableImageButton findCheckableImageButton(View view) {
    if (view instanceof CheckableImageButton) {
        return (CheckableImageButton)view;
    }

    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0,ei = viewGroup.getChildCount(); i < ei; i++) {
            CheckableImageButton checkableImageButton = findCheckableImageButton(viewGroup.getChildAt(i));
            if (checkableImageButton != null) {
                return checkableImageButton;
            }
        }
    }

    return null;
}

//...

if (passwordEditText.getTransformationMethod() != null) {
    CheckableImageButton checkableImageButton = findCheckableImageButton(passwordTextInputLayout);
    if (checkableImageButton != null) {
        // Make password visible.
        checkableImageButton.performClick();
    }
}

我们今天的关于React Table toggleRowExpanded 不起作用react-table的分享就到这里,谢谢您的阅读,如果想了解更多关于Android ExpandableListActivity和SimpleCursorTreeAdapter?、Android M – GoogleAccountCredential setSelectedAccount不起作用 – 名称不能为null、android – clearAllTables不起作用、android – 使用TextInputLayouts passwordToggleEnabled的可见密码的相关信息,可以在本站进行搜索。

本文标签: