das ist mein Layout:add Ansicht dynamisch über zwei bereits erstellte Schaltfläche in relativ Layout in android
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="evip.gohybrid.com.evip.ShowBarcode">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnaddtoprofile"
android:text="Add to Profile"
android:textStyle="bold"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:gravity="center"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btncancel"
android:text="Cancel"
android:textStyle="bold"
android:textSize="20dp"
android:layout_below="@+id/btnaddtoprofile"
android:gravity="center"/>
dies ist mein Code:
Bitmap bitmap = null;
ImageView iv = new ImageView(this);
try {
bitmap = encodeAsBitmap(code, BarcodeFormat.CODE_128, 600, 300);
iv.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
relativelayout.addView(iv);
//barcode text
TextView tv = new TextView(this);
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setText(code);
tv.setTextSize(25);
relativelayout.addView (tv) ;
ich möchte imageview oben und dann textview dynamisch hinzufügen und dann die zwei taste die ist in meiner layout-datei .... wie kann ich es tun ...? kann mir jemand einen Vorschlag geben ..?
können Sie mir antworten plz ..? –