如何刷新以编程方式创建的布局?

时间:2017-12-14 06:07:35

标签: android

我的情况就像我在from Bio import PDB import numpy as np parser = PDB.PDBParser() io = PDB.PDBIO() struct = parser.get_structure('1abz','1abz.pdb') for model in struct: for chain in model: for residue in chain: for atom in residue: def rotmat(): rotation = rotmat(np.pi, Vector(0.0, 0.0, 0.0)) translation = np.array((0.0, 0.0, 0.0), 'f') atom.transform(rotation, translation) io.set_structure(struct) io.save('1abz_coord.pdb') 内以编程方式创建自定义布局一样。例如:

onCreateView()

不,我想问的是如何刷新 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return createLayout(cView); } View createLayout(View view) { LinearLayout linLayout = new LinearLayout(activity); linLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams linLayoutParam = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); linLayout.setLayoutParams(linLayoutParam); for (int i = 0; i <= 3; i++) { TextView tv = new TextView(activity); tv.setId(i); tv.setText("TextView"); tv.setLayoutParams(lpView); linLayout.addView(tv); } view = linLayout; return view; } @Override public void onResume() { super.onResume(); } 来自textview的ID?感谢。

2 个答案:

答案 0 :(得分:2)

您可以使用textview的id键将您的textview保存在hashmap中。然后在你的简历上。您可以通过id获取该textview并刷新它。

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>
#<IfModule mod_rewrite.c>
#    RewriteEngine On
#    RewriteCond %{REQUEST_FILENAME} !-f
#    RewriteCond %{REQUEST_FILENAME} !-d
#    RewriteRule ^(.*)$ index.php/$1 [L]
#</IfModule>

在创建此文本视图时,在创建方法中,您需要将textview放在hashmap中。

private HashMap<Integer,TextView> textViews = new HashMap<>();

你的onResume方法应该如下所示

for (int i = 0; i <= 3; i++) {
    TextView tv = new TextView(activity);
    tv.setId(i);
    tv.setText("TextView");
    tv.setLayoutParams(lpView);
    linLayout.addView(tv);
    textViews.put(i,tv);
}

答案 1 :(得分:0)

TextView tv 设为全局,并像往常一样更新此电视。