我应该怎么做才能从AsyncTask中的onPostExecute方法向现有的线性布局中添加新的TextView(在代码中带有文本“ inf1”和“ inf2”)?
module.exports = function(Model, options) {
Model.observe("before save", async function(ctx) {
if (ctx.instance.id) return;
const userId = ctx.options && ctx.options.accessToken && ctx.options.accessToken.userId;
if (userId) {
//... do stuff
}
else
{
console.error("Failed to scope " + Model.name + " to user (null)");
}
});
};
答案 0 :(得分:0)
找到视图,然后向其添加子视图:
LinearLayout layout_named_feedFetch=(LinearLayout)findViewById(R.id.feedFetch);
//or call the_parent_view_of_feedFetch.findViewById() if it's the child another view;
for(int x=0; x < result.length(); x++) {
JSONObject collegeData = result.getJSONObject(x);
inf1 = collegeData.getString("title");
inf2 = collegeData.getString("text");
//create the new views
TextView tv=new TextView(getApplicationContext());
//add them to where you want
layout_named_feedFetch.addView(tv);
//assign values to them
tv.setText(inf1+" "+inf2);
}