Webview dans créé par programmation RelativeLayout
J'ai besoin le code xml suivant pour être faite dans le code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:gravity="right"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000"
>
<android.webkit.WebView android:layout_width="fill_parent"
android:id="@+id/adview"
android:scrollbars="none"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
></android.webkit.WebView>
<Button android:layout_width="wrap_content" android:text="x" android:textColor="#000000"
android:layout_height="wrap_content" android:id="@+id/hide_popup_button" android:background="#00000000"
android:layout_alignTop="@+id/adview" android:layout_alignParentRight="true"></Button>
</RelativeLayout>
J'utilise le code ci-dessous mais je reçois un Force close
:
RelativeLayout popwindow=new RelativeLayout(this);
RelativeLayout.LayoutParams rl= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
popwindow.setLayoutParams(rl);
WebView w= new WebView(this);
w.setId(0X100);
w.setScrollContainer(false);
android.widget.RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)w.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
Button b=new Button(this);
b.setId(0X101);
b.setText("X");
b.setBackgroundColor(Color.TRANSPARENT);
b.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
android.widget.RelativeLayout.LayoutParams paramsbut = (RelativeLayout.LayoutParams)b.getLayoutParams();
paramsbut.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
paramsbut.addRule(RelativeLayout.ALIGN_TOP,w.getId() );
popwindow.addView(w,params);
popwindow.addView(b,paramsbut);
setContentView(popwindow);
J'ai besoin de suggestions sur la façon de faire que xml pour la mise en page de code java.
essayez LayoutParams param = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); w.setLayoutParams(param); à la place d'android.widget de.RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)w.getLayoutParams();
se "forcer la fermeture" afficher le journal de chat ainsi..
exception de pointeur null
Si je modifier pour améliorer votre question, merci de ne pas annuler les changements.
se "forcer la fermeture" afficher le journal de chat ainsi..
exception de pointeur null
Si je modifier pour améliorer votre question, merci de ne pas annuler les changements.
OriginalL'auteur Shalini | 2012-06-27
Vous devez vous connecter pour publier un commentaire.
Vous devriez poster une exception que vous obtenez dans votre question. Voir si cela aide:
Composant personnalisé tenant le
WebView
et laButton
:Utilisation de ce composant:
oui. j'utilise le code ci-dessus dans une autre classe qui s'étend de mise en page et utilisez le bouton et webview dans mainclass
Vérifier mon édité réponse.
Merci pour les dépenses de m'votre temps. je vais essayer maintenant 🙂
Je reçois le bouton et webview l'aide de votre code. Mais maintenant, comment puis-je obtenir toute la mise en page et la renvoyer dans la classe principale. ex:TransparentPanel tp=(TransparentPanel) findViewById(thatlayourhere?);
OriginalL'auteur Luksprog