Ich versuche, eine Ansicht abzurufen, aber sie gibt immer null zurück, wie finde ich sie?Wie finde ich viewbyid einer Ansicht innerhalb eines Tabhost von einer Aktivität, die innerhalb des Tabhost ist?
public class TripDailyItinerary extends Activity {
ViewGroup layout;
View v;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.html_content);
TextView content = (TextView) findViewById(R.id.htmlContent);
layout = (ViewGroup) findViewById(R.layout.trip_content);
v = (View) layout.findViewById(R.id.bg); //where the error is
JSONObject reservation;
int resNumber = ((MyApp) this.getApplication()).getResNum();
String dailyitinerary = "";
try {
reservation = ((MyApp) this.getApplication()).getJSON().getJSONObject("response").getJSONArray("reservations").getJSONObject(resNumber);
dailyitinerary = reservation.getString("dailyitinerary");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
content.setText(Html.fromHtml(dailyitinerary));
}
}
Ich halte eine Nullpointer bei v bekommen = (Ansicht) .... usw.
teilen Sie Ihren Code .. –
Sie müssen überprüfen Sie Ihre ViewId korrekt in Ihrem Layout.Teilen Sie den Code und kürzen Sie die Frage Beschreibung, wie es noch größer ist als die eigentliche Frage. – Sankalp
Post einige Code ... –