Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中更新弹出窗口中的listview_Android_Listview_Popup - Fatal编程技术网

如何在Android中更新弹出窗口中的listview

如何在Android中更新弹出窗口中的listview,android,listview,popup,Android,Listview,Popup,我有一个标题为“所有文章”的文本视图。我正在显示弹出窗口单击文本视图,并在弹出窗口中用两个项目填充列表视图。尝试实现这一点-每当单击列表视图项目时,该项目将显示在文本视图中,以前的文本视图标题所有文章将添加到列表视图中可单击项目的位置。但是我的listview不会在弹出窗口中更新 String[] values = new String[] { "All Post", "My Post", "R-Post"}; ArrayList<String> filter

我有一个标题为“所有文章”的文本视图。我正在显示弹出窗口单击文本视图,并在弹出窗口中用两个项目填充列表视图。尝试实现这一点-每当单击列表视图项目时,该项目将显示在文本视图中,以前的文本视图标题所有文章将添加到列表视图中可单击项目的位置。但是我的listview不会在弹出窗口中更新

      String[] values = new String[] { "All Post", "My Post", "R-Post"};
      ArrayList<String> filter_PostType = new ArrayList<String>();
      str_LastSelectionValue  =  sharedPreferences.getString("filter_post_title", "");

       if(str_LastSelectionValue.equals("NoVal"))
        {
            editor.putString("filter_post_title","All Post");
            editor.commit();
        }
        else
        {
            str_LastSelectionValue  = sharedPreferences.getString("filter_post_title", "");
        }
        textSearch.setText(str_LastSelectionValue);
        Log.e("", " textSearch.getText().toString().trim() = " +   
        textSearch.getText().toString().trim());

    textSearch.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v)
                {

                        popup_searchview = new PopupWindow(CustomActionActivity.this);
                        View layout = getLayoutInflater().inflate(R.layout.allpostsearch_popup, null);
                        popup_searchview.setContentView(layout);
                        popup_searchview.setHeight(220);
                        popup_searchview.setWidth(250);

                        popup_searchview.setOutsideTouchable(true);
                        popup_searchview.setFocusable(true);
                        popup_searchview.setBackgroundDrawable(new BitmapDrawable());
                        popup_searchview.showAsDropDown(v);


                        filter_list = (ListView) layout.findViewById(R.id.filter_ListView);
                        arr = new ArrayList<String>(Arrays.asList(values));
                        filter_PostType.clear();

                        for (int i = 0; i < arr.size(); i++) {
                            String str_PostType = arr.get(i);

                            if (!str_PostType.equals(str_LastSelectionValue)) {
                                filter_PostType.add(str_PostType);

                            }
                        }

                        filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.filter_popup_list_item, R.id.text_filter_title, filter_PostType);
                        filter_list.setAdapter(filterPost_adapter);

                        filter_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                                String selectedFromList = (filter_list.getItemAtPosition(position).toString());
                                editor.putString("filter_post_title", selectedFromList);
                                editor.commit();
                                textSearch.setText(selectedFromList);
                                popup_searchview.dismiss();

                                removeItemFromList(position);
                                filterPost_adapter.notifyDataSetChanged();

                                arr = new ArrayList<String>(Arrays.asList(values));
                                filter_PostType.clear();
                                for (int i = 0; i < arr.size(); i++)
                                {
                                    String str_PostType = arr.get(i);

                                    if (!str_PostType.equals(textSearch.getText().toString().trim()))
                                    {

                                        filter_PostType.add(str_PostType);
                                        int filterSize = filter_PostType.size();
                                        Log.e(" UnMatched ", " In ListItem Click filterSize = " + filterSize);
                                    }
                                }


                                filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.filter_popup_list_item, R.id.text_filter_title, filter_PostType);
                                filter_list.setAdapter(filterPost_adapter);

                             }
                        });
                   }
            });
这是我的弹出窗口代码

      String[] values = new String[] { "All Post", "My Post", "R-Post"};
      ArrayList<String> filter_PostType = new ArrayList<String>();
      str_LastSelectionValue  =  sharedPreferences.getString("filter_post_title", "");

       if(str_LastSelectionValue.equals("NoVal"))
        {
            editor.putString("filter_post_title","All Post");
            editor.commit();
        }
        else
        {
            str_LastSelectionValue  = sharedPreferences.getString("filter_post_title", "");
        }
        textSearch.setText(str_LastSelectionValue);
        Log.e("", " textSearch.getText().toString().trim() = " +   
        textSearch.getText().toString().trim());

    textSearch.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v)
                {

                        popup_searchview = new PopupWindow(CustomActionActivity.this);
                        View layout = getLayoutInflater().inflate(R.layout.allpostsearch_popup, null);
                        popup_searchview.setContentView(layout);
                        popup_searchview.setHeight(220);
                        popup_searchview.setWidth(250);

                        popup_searchview.setOutsideTouchable(true);
                        popup_searchview.setFocusable(true);
                        popup_searchview.setBackgroundDrawable(new BitmapDrawable());
                        popup_searchview.showAsDropDown(v);


                        filter_list = (ListView) layout.findViewById(R.id.filter_ListView);
                        arr = new ArrayList<String>(Arrays.asList(values));
                        filter_PostType.clear();

                        for (int i = 0; i < arr.size(); i++) {
                            String str_PostType = arr.get(i);

                            if (!str_PostType.equals(str_LastSelectionValue)) {
                                filter_PostType.add(str_PostType);

                            }
                        }

                        filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.filter_popup_list_item, R.id.text_filter_title, filter_PostType);
                        filter_list.setAdapter(filterPost_adapter);

                        filter_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                                String selectedFromList = (filter_list.getItemAtPosition(position).toString());
                                editor.putString("filter_post_title", selectedFromList);
                                editor.commit();
                                textSearch.setText(selectedFromList);
                                popup_searchview.dismiss();

                                removeItemFromList(position);
                                filterPost_adapter.notifyDataSetChanged();

                                arr = new ArrayList<String>(Arrays.asList(values));
                                filter_PostType.clear();
                                for (int i = 0; i < arr.size(); i++)
                                {
                                    String str_PostType = arr.get(i);

                                    if (!str_PostType.equals(textSearch.getText().toString().trim()))
                                    {

                                        filter_PostType.add(str_PostType);
                                        int filterSize = filter_PostType.size();
                                        Log.e(" UnMatched ", " In ListItem Click filterSize = " + filterSize);
                                    }
                                }


                                filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.filter_popup_list_item, R.id.text_filter_title, filter_PostType);
                                filter_list.setAdapter(filterPost_adapter);

                             }
                        });
                   }
            });
String[]values=新字符串[]{“所有帖子”、“我的帖子”、“R-Post”};
ArrayList筛选器_PostType=新建ArrayList();
str_LastSelectionValue=SharedReferences.getString(“filter_post_title”,”);
if(str_LastSelectionValue.equals(“NoVal”))
{
编辑器.putString(“过滤文章标题”、“所有文章”);
commit();
}
其他的
{
str_LastSelectionValue=SharedReferences.getString(“filter_post_title”,”);
}
textSearch.setText(str_LastSelectionValue);
Log.e(“,”textSearch.getText().toString().trim()=”+
textSearch.getText().toString().trim());
textSearch.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v)
{
popup\u searchview=new PopupWindow(CustomActionActivity.this);
视图布局=GetLayoutFlater()。充气(R.layout.allpostsearch\u弹出窗口,空);
弹出搜索视图。设置内容视图(布局);
弹出搜索视图。设置高度(220);
弹出搜索视图。设置宽度(250);
弹出搜索视图。setOutsideTouchable(真);
popup_searchview.setFocusable(true);
popup_searchview.setBackgroundDrawable(新的BitmapDrawable());
弹出搜索视图。显示下拉列表(v);
filter\u list=(ListView)layout.findViewById(R.id.filter\u ListView);
arr=newarraylist(Arrays.asList(values));
filter_PostType.clear();
对于(int i=0;i
使用类似以下内容:

    String[] values = new String[] { "All Post", "My Post", "R-Post"};
        ArrayList<String> filter_PostType = new ArrayList<String>();
        str_LastSelectionValue  =  sharedPreferences.getString("filter_post_title", "NoVal");

         if(str_LastSelectionValue.equals("NoVal"))
          {
              editor.putString("filter_post_title","All Post");
              editor.commit();
          }
          else
          {
              str_LastSelectionValue  = sharedPreferences.getString("filter_post_title", "");
          }
          textSearch.setText(str_LastSelectionValue);
          Log.e("", " textSearch.getText().toString().trim() = " +   
          textSearch.getText().toString().trim());

      textSearch.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v)
                  {
                           str_LastSelectionValue = sharedPreferences.getString("filter_post_title", ""); 
                          popup_searchview = new PopupWindow(CustomActionActivity.this);
                          View layout = getLayoutInflater().inflate(R.layout.allpostsearch_popup, null);
                          popup_searchview.setContentView(layout);
                          popup_searchview.setHeight(220);
                          popup_searchview.setWidth(250);

                          popup_searchview.setOutsideTouchable(true);
                          popup_searchview.setFocusable(true);
                          popup_searchview.setBackgroundDrawable(new BitmapDrawable());
                          popup_searchview.showAsDropDown(v);


                          filter_list = (ListView) layout.findViewById(R.id.filter_ListView);
                          if(!filter_PostType.isEmpty())
                          filter_PostType.clear();

                          for (int i = 0; i < values.length; i++) {


                              if (!values[i].equals(str_LastSelectionValue)) {
                                  filter_PostType.add(values[i]);

                              }
                          }

                          filterPost_adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.filter_popup_list_item, R.id.text_filter_title, filter_PostType);
                          filter_list.setAdapter(filterPost_adapter);

                          filter_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                              @Override
                              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                                  String selectedFromList = (filter_list.getItemAtPosition(position).toString());
                                  editor.putString("filter_post_title", selectedFromList);
                                  editor.commit();
                                  str_LastSelectionValue=selectedFromList;
                                  textSearch.setText(selectedFromList);
                                  popup_searchview.dismiss();

                               }
                          });
                     }
              });


}
String[]values=新字符串[]{“所有帖子”、“我的帖子”、“R-Post”};
ArrayList筛选器_PostType=新建ArrayList();
str_LastSelectionValue=SharedReferences.getString(“filter_post_title”,“NoVal”);
if(str_LastSelectionValue.equals(“NoVal”))
{
编辑器.putString(“过滤文章标题”、“所有文章”);
commit();
}
其他的
{
str_LastSelectionValue=SharedReferences.getString(“filter_post_title”,”);
}
textSearch.setText(str_LastSelectionValue);
Log.e(“,”textSearch.getText().toString().trim()=”+
textSearch.getText().toString().trim());
textSearch.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v)
{
str_LastSelectionValue=SharedReferences.getString(“filter_post_title”,”);
popup\u searchview=new PopupWindow(CustomActionActivity.this);
视图布局=GetLayoutFlater()。充气(R.layout.allpostsearch\u弹出窗口,空);
弹出搜索视图。设置内容视图(布局);
弹出搜索视图。设置高度(220);
弹出搜索视图。设置宽度(25