///我正在从allShops中的数据库获取数据
JsonArrayRequest jsonArrayRequest;
jsonArrayRequest = new JsonArrayRequest(url,new Response.Listener(){
@Override
公共无效onResponse(JSONArray response){
for (int i = 0; i < response.length(); i++) {
try {
JSONObject jsonObject = response.getJSONObject(i);
//allShops is an arraylist
allShops.add(jsonObject.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
//user enters text in edittext et_search
et_search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence cs, int start, int before, int count)
{
}
@Override
public void afterTextChanged(Editable s) {
//here i am adding arraylist to adapter but want it to happen after filtering the arraylist first based on users input
adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,allShops);
(Search.this).adapter.getFilter().filter(s);
lv_search.setAdapter(adapter);
}
});
答案 0 :(得分:0)
我更新了代码的不足部分:
function updatePermissions(Request $request)
{
if (!hasRole('SuperAdmin') && !userCan('attach_permissions')) {
abort('404');
}
$roleId = $request->input('role_id');
$permIds = $request->input('perm');
$role = Role::where('id', '=', $roleId)->first();
if (!$role) {
abort('404');
}
if ($permIds == null) {
$role = Role::findOrFail($roleId);
$role_permissions = $role->perms()->get();
//print_r($role_permissions);exit;
$rolePermIds = array();
foreach ($role_permissions as $permission) {
$rolePermIds[] = $permission->id;
}
$role->perms()->detach($rolePermIds);
} else {
/*$role->perms()->sync(array_keys($permIds));*/
$permissions_new = (array_keys($permIds));
RolePermission::where('role_id', '=', $roleId)->forceDelete();
foreach ($permissions_new as $item) {
$r = new RolePermission();
$r->role_id = $role->id;
$r->permission_id = $item;
$r->save();
}
}
return redirect()->back();
}