我有一个CustomView,它在View上显示一个数字,这个数字来自数据库。当我移动到另一个Activity时,更改数据库数量并调用finish();
方法时,第一个Activity将显示,并且我想刷新或重新加载在第一次加载中初始化以显示其更新值的CustomView。这怎么可能?在Android中刷新/重新加载CustomView
这里是我的CustomClass:
public class Navigation extends LinearLayout {
public Navigation(Context context) {
super(context);
this.initComponent(context);
}
public Navigation(Context context, AttributeSet attrs) {
super(context, attrs);
this.initComponent(context);
}
private void initComponent(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.navigation_bar, null, false);
this.setOrientation(VERTICAL);
this.addView(v);
LinearLayout workorder = (LinearLayout) v.findViewById(R.id.workorder);
PersianTextView workorder_count = (PersianTextView) v.findViewById(R.id.workorder_count);
workorder.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
getContext().startActivity(new Intent(getContext(),Workorders.class));
}
});
database db = new database(getContext());
db.open();
Cursor cu = db.Display_shared("SELECT * FROM [Workorder_Repair] WHERE [Workorder_Repair_For_Department_ID] = "+ Login.dep_id+" AND [Workorder_Repair_Status] = 1");
if(cu.getCount()>0)
workorder_count.setText(""+cu.getCount());
else
workorder_count.setVisibility(INVISIBLE);
}
我用它在近15的活动,我想刷新
如何显示在第一View中的数地点?这应该是完全相同的。 –
另外,你如何开始第二个活动?你正在使用startActivity()或startActivityForResult()吗? –
我通过staratActivity()方法开始它 –