Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.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中重新加载_Android - Fatal编程技术网

活动不会在Android中重新加载

活动不会在Android中重新加载,android,Android,我有两个活动,我将在下一个活动中实现更新查询,我希望在我的列表视图中添加到上一个活动中的更新行。我尝试更新数据库表行,但列表视图未更新。如何解决此问题。有人可以帮助我吗 这是我在数据库助手类中从Sq Lite填充列表视图 public List<All_Post> getAllDescriptions() { List<All_Post> allPostDescList = new ArrayList<All_Post>();

我有两个活动,我将在下一个活动中实现更新查询,我希望在我的列表视图中添加到上一个活动中的更新行。我尝试更新数据库表行,但列表视图未更新。如何解决此问题。有人可以帮助我吗

这是我在数据库助手类中从Sq Lite填充列表视图

public List<All_Post> getAllDescriptions()
     {
        List<All_Post> allPostDescList = new ArrayList<All_Post>();
        String selectQuery = "select * from  " + Table_AllPost_Table + " where  ActiveStatus = '1' ORDER BY ActionDate DESC";

        db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        if (cursor.moveToFirst()) {
            do
            {
                All_Post allPostDesc = new All_Post();
                allPostDesc.setID(cursor.getInt(cursor.getColumnIndex("ALL_ACT_ID")));
                allPostDesc.setStrActiveStatus(cursor.getString(cursor.getColumnIndex("ActiveStatus")));
                allPostDesc.setStrActivityId(cursor.getString(cursor.getColumnIndex("ActivityId")));
                allPostDesc.setStrRemark(cursor.getString(cursor.getColumnIndex("Remark")));
                allPostDesc.setStringInspectorname(cursor.getString(cursor.getColumnIndex("inspectorName")));
                allPostDesc.setStrNotationNo(cursor.getString(cursor.getColumnIndex("HashTag")));
                allPostDesc.setStrShortName(cursor.getString(cursor.getColumnIndex("Type_ShortRGN")));
                allPostDesc.setStrUserId(cursor.getString(cursor.getColumnIndex("UserId")));
                allPostDesc.setStrvessel_Id(cursor.getString(cursor.getColumnIndex("VesselId")));
                String strSqliteDate = cursor.getString(cursor.getColumnIndex("ActionDate"));
                DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
                Date parsed = null;
                try
                {
                    parsed = outputFormat.parse(strSqliteDate);
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                String outputText = outputFormat.format(parsed);

                allPostDesc.setActiondate(outputText);

                allPostDescList.add(allPostDesc);
            } while (cursor.moveToNext());
        }
         cursor.close();
         db.close();
        return allPostDescList;
    }
公共列表getAllDescriptions() { List allPostDescList=新建ArrayList(); String selectQuery=“select*from”+Table\u AllPost\u Table+,其中ActiveStatus='1'按ActionDate DESC排序”; db=this.getWritableDatabase(); Cursor Cursor=db.rawQuery(selectQuery,null); if(cursor.moveToFirst()){ 做 { All_Post allPostDesc=新的All_Post(); allPostDesc.setID(cursor.getInt(cursor.getColumnIndex(“ALL_ACT_ID”)); allPostDesc.SetTractiveStatus(cursor.getString(cursor.getColumnIndex(“ActiveStatus”)); allPostDesc.SetTractivityId(cursor.getString(cursor.getColumnIndex(“ActivityId”)); allPostDesc.setStrRemark(cursor.getString(cursor.getColumnIndex(“Remark”)); allPostDesc.SetString名称(cursor.getString(cursor.getColumnIndex(“inspectorName”)); allPostDesc.setStrNotationNo(cursor.getString(cursor.getColumnIndex(“HashTag”)); allPostDesc.setStrShortName(cursor.getString(cursor.getColumnIndex(“Type_ShortRGN”)); allPostDesc.setTruserID(cursor.getString(cursor.getColumnIndex(“UserId”)); allPostDesc.setStrvessel_Id(cursor.getString(cursor.getColumnIndex(“VesselId”)); String strSqliteDate=cursor.getString(cursor.getColumnIndex(“ActionDate”); DateFormat outputFormat=新的SimpleDateFormat(“yyyy-MM-dd”,Locale.ENGLISH); 解析日期=空; 尝试 { parsed=outputFormat.parse(strSqliteDate); }捕获(解析异常){ //TODO自动生成的捕捉块 e、 printStackTrace(); } 字符串outputText=outputFormat.format(已解析); allPostDesc.setActiondate(输出文本); 添加(allPostDesc); }while(cursor.moveToNext()); } cursor.close(); db.close(); 返回allPostDescList; } 这是我在Sq Lite中的填充列表视图

@Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.all_post);

        ctx = this;

        dbhelper = new MyDbHelper(this);
        dbhelper.onOpen(db);

        imgLeftmenu = (ImageView) findViewById(R.id.imgLeftMenu);
        imgSearch = (ImageView) findViewById(R.id.imgSearch);
        imgAdd = (ImageView) findViewById(R.id.imgAdd);

        listView = (ListView) findViewById(R.id.listview_AllPost);
        Log.e(" After "," Filter Screen !!! ");
        populateList();

}

 @Override
    protected void onResume() {
        super.onResume();
        populateList();
    }
    private void populateList() {
            descArray.clear();

            List<All_Post> allDesc = dbhelper.getAllDescriptions();
            for (All_Post all_Post : allDesc)
            {
                String strInspectorname = all_Post.getStringInspectorname();
                Log.e("strInspectorname "," = " + strInspectorname);
                descArray.add(all_Post);
            }

            if (adapter == null)
            {
                Log.e("Adapter ", " == Null !!!! ");
                adapter = new MyListAdapter(this, R.layout.all_post_row, descArray);
                listView.setAdapter(adapter);

            }
            else if (adapter != null)
            {
                Log.e("Adapter ", " != Null !!!! ");
                adapter.notifyDataSetChanged();
                adapter = new MyListAdapter(this, R.layout.all_post_row, descArray);
                listView.setFastScrollEnabled(true);
                listView.setAdapter(adapter);
            }
        }
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(右布局,所有帖子);
ctx=这个;
dbhelper=新的MyDbHelper(此);
dbhelper.onOpen(db);
imgLeftmenu=(ImageView)findViewById(R.id.imgLeftmenu);
imgSearch=(ImageView)findViewById(R.id.imgSearch);
imgAdd=(ImageView)findViewById(R.id.imgAdd);
listView=(listView)findViewById(R.id.listView\u AllPost);
Log.e(“之后”,“过滤屏幕!!!”);
大众主义者();
}
@凌驾
受保护的void onResume(){
super.onResume();
大众主义者();
}
私有void populateList(){
descArray.clear();
List allDesc=dbhelper.getAllDescriptions();
for(所有发布所有发布:所有描述)
{
String strInspectorname=all_Post.getStringInspectorname();
Log.e(“strInspectorname”,“=”+strInspectorname);
descArray.add(所有_Post);
}
if(适配器==null)
{
Log.e(“适配器”,“==Null!!!!”);
适配器=新的MyListAdapter(此,R.layout.all\u post\u行,descArray);
setAdapter(适配器);
}
else if(适配器!=null)
{
Log.e(“适配器”,“!=Null!!!!”);
adapter.notifyDataSetChanged();
适配器=新的MyListAdapter(此,R.layout.all\u post\u行,descArray);
setFastScrollEnabled(true);
setAdapter(适配器);
}
}
下面是我在onCreate()中的下一个活动代码

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filter_屏幕);
ctx=这个;
Log.e(“我”、“在过滤器中!!!”);
dbhelper=新的MyDbHelper(此);
dbhelper.onOpen(db);
SharedReferences SharedReferences=PreferenceManager.GetDefaultSharedReferences(getApplicationContext());
str_Authentication_Token=SharedReferences.getString(“strAuthentication_Token”,下称“);
str_UserId=SharedReferences.getString(“strUserId”,即“”);
str_UserName=SharedReferences.getString(“strUserName”,即“”);
imgProfilePic=(ImageView)findViewById(R.id.img_ProfilePic);
imgBtn_LogOut=(ImageView)findViewById(R.id.img_LogOut);
listView\u Filter=(listView)findViewById(R.id.Filter\u List);
txtUserName=(TextView)findViewById(R.id.txt_用户名);
txtUserName.setText(str_用户名);
userAutoComplete\u TextView=(AutoCompleteTextView)findViewById(R.id.autoComplete\u UserList);
db=dbhelper.getWritableDatabase();
String query=“从检查器中选择*”;
Cursor Cursor=db.rawQuery(查询,空);
if(cursor.moveToFirst()){
做{
过滤器=新过滤器();
filter.setName(cursor.getString(cursor.getColumnIndex(“Inspector_name”));
String strActiveStatus=cursor.getString(cursor.getColumnIndex(“ActiveStatus”);
String strInspectorname=cursor.getString(cursor.getColumnIndex(“检查器名称”);
如果(strActiveStatus.equals(“1”)){
添加(strInspectorname);
  public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.filter_screen);
        ctx = this;
        Log.e("I m", " in Filter !!!");
        dbhelper = new MyDbHelper(this);
        dbhelper.onOpen(db);

        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        str_Authentication_Token = sharedPreferences.getString("strAuthentication_Token", "");
        str_UserId = sharedPreferences.getString("strUserId", "");
        str_UserName = sharedPreferences.getString("strUserName", "");

        imgProfilePic = (ImageView) findViewById(R.id.img_ProfilePic);

        imgBtn_LogOut = (ImageView) findViewById(R.id.img_LogOut);
        listView_Filter = (ListView) findViewById(R.id.filter_List);
        txtUserName = (TextView) findViewById(R.id.txt_Username);

        txtUserName.setText(str_UserName);
        userAutoComplete_TextView = (AutoCompleteTextView) findViewById(R.id.autoComplete_UserList);

        db = dbhelper.getWritableDatabase();
        String query = "select * from Inspector";
        Cursor cursor = db.rawQuery(query, null);
        if (cursor.moveToFirst()) {
            do {
                Filter filter = new Filter();
                filter.setName(cursor.getString(cursor.getColumnIndex("Inspector_name")));
                String strActiveStatus = cursor.getString(cursor.getColumnIndex("ActiveStatus"));
                String strInspectorname = cursor.getString(cursor.getColumnIndex("Inspector_name"));

                if (strActiveStatus.equals("1")) {
                    userlist.add(strInspectorname);
                    Log.e("strInspectorname", " from Inspector = " + strInspectorname + "  & strActiveStatus  = " + strActiveStatus);
                }

            } while (cursor.moveToNext());
        }
        cursor.close();
        db.close();

        userAutoComplete_TextView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, userlist));
        userAutoComplete_TextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                String foundItem = arg0.getItemAtPosition(arg2).toString();
                Log.e("You have selected --->", "" + foundItem);
                Filter filter = new Filter();
                filter.setName(foundItem);
                filter_ArrayList.add(filter);
                filterAdapter = new FilterAdapter(Filter_Screen.this, R.layout.filter_list_item, filter_ArrayList);
                listView_Filter.setAdapter(filterAdapter);
                db = dbhelper.getWritableDatabase();
                db.execSQL("UPDATE ALL_Post SET ActiveStatus ='1' WHERE inspectorName ='" + foundItem + "'");
                Log.e("Updated ListView --->", "" + foundItem);

            }
        });
}