0
如何讓我的「sodrzina」在其他xml佈局上顯示..您可以看到我用setContentView(R.layout.sodrzina)進行了幾次嘗試; ..用這些方法,我點擊打開其他佈局,但沒有內容。如何在那裏展示我的內容?將我的文本視圖重定向到其他佈局
View.OnClickListener
getOnClickDoSomething(final Button button) {
return new View.OnClickListener() {
public void onClick (View v){
//TextView View = (TextView) findViewById(R.id.viewSodrzina);
setContentView(R.layout.sodrzina);
TextView View = (TextView) findViewById(R.id.viewSodrzina);
String sodrzina="";
}
}
String sodrzina="";
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.cook-recipes.hostoi.com/jsonscript/sodrzina.php?sodrzina="+(button.getText()).toString().replace(" ","%20"));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream webs = entity.getContent();
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(webs,"iso-8859-1"),8);
//myListView.setText(reader.readLine());
int askiChar=0;
while((askiChar =reader.read())!=-1)
{
sodrzina+= ((char)askiChar);
}
webs.close();
reader.close();
}catch(Exception e){
Log.e("log_tag","Error converting reslt"+e.toString());
}
//TextView prikaziSodrzina = (TextView)findViewById(R.id.viewSodrzina);
//Toast.makeText(Desert.this,sodrzina, Toast.LENGTH_LONG).show();
//prikaziSodrzina.append(sodrzina);
// View.append(sodrzina);
}
catch (Exception e)
{
Log.e("ERROR","ERROR IN CODE: "+e.toString());
e.printStackTrace();
}
}
但是,這些內容是由動態按鈕生成的,我需要代碼幫助 – AndroDevelop 2013-04-21 12:12:00
我解決了我的自我:我做了佈局方法,並把id放在新佈局的文本視圖上。所以現在一切都好。謝謝大家 – AndroDevelop 2013-04-22 17:19:29