我有一个显示布局与两个项目其中之一是imageView和另一个是TextView.I'm使用此布局显示很多东西,但有一个问题。问题是让我们说我跑一个活动使用这种布局这个活动填充它并杀死自己。后来如果我打电话给另一个活动使用该布局它改变图像,但文字仍然same.I不想发布所有的代码,但如果你们需要我可以发布它。Android TextView文本更改错误
setContentView(R.layout.info_display_tablet);
iv = (ImageView) findViewById(R.id.imageView1);
tx = (TextView) findViewById(R.id.textView1);
try {
result = MethodInfoGetter.methodRequest("CTVIslemleriGetir", "", "");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tx.setText("");
iv.setImageResource(R.drawable.cevre_temizlik);
tx.setText(result.get(0).get(1).toString());
这是我的第一个电话让我们asume的第二呼叫的代码是
public class BalikesirTarih extends Activity
{
ArrayList<ArrayList> result = new ArrayList<ArrayList>();
ImageView iv;
TextView tx;
Bitmap bmp = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.info_display_tablet);
iv = (ImageView) findViewById(R.id.imageView1);
tx = (TextView) findViewById(R.id.textView1);
try {
result = MethodInfoGetter.methodRequest("BalikesirTarihiGetir", "", "");
Log.i("Balikesir tarihi log denemesi",result.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new asTask().execute();
}
private class asTask extends AsyncTask<Void , Void ,Void> {
@Override
protected Void doInBackground(Void... params) {
URL url = null;
try {
url = new URL("http://balikesir.bel.tr/Balikesir_Tarihi/Resim_b_1.jpg");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
iv.setImageBitmap(bmp);
tx.setText("");
tx.setText(result.get(0).get(1).toString());
}
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}
你不必发布你所有的代码,但没有相关的位,我们不会能够帮助你。 –
每次加载时,文本将作为'layout.xml'文件中的默认文本,除非您保存该值并在膨胀'layout时特别设置它。我认为你需要提供*一些*代码和/或更好的解释,因为这很混乱。 – codeMagic
这是我在程序中调用的代码。 –