Je tente d'afficher une nouvelle vue en haut de ma vue principale.Android View ne s'affiche pas
Voici le XML pour la nouvelle vue:
<RelativeLayout
android:id="@+id/mapdetaillayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:text="This is the Text from the XML File."
android:id="@+id/DetailTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</RelativeLayout>
Et voici le code que je utilise pour pousser la nouvelle viev sur l'écran:
RelativeLayout DetailLayout = new RelativeLayout(c);
LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.mapdetailview, DetailLayout);
TextView tv = (TextView) v.findViewById(R.id.DetailTextView);
tv.setText("HERE IS THE TEXT FROM THE CODE");
// This Log works
Log.i("MESSAGE", tv.getText());
DetailLayout.setBackgroundColor(Color.WHITE);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.NO_GRAVITY;
DetailLayout.bringToFront();
DetailLayout.setVisibility(View.VISIBLE);
Le code est appelé et le journal affiche le texte attendu, ce qui pour moi indique que la vue a été créée - elle n'est simplement pas affichée à l'écran.
Toute aide serait appréciée.
Pourquoi vous faites cela? On dirait quelque chose de complètement faux pour moi. –