I'm having a strange trouble and didn't find any solutions on the web.
I'm adding a TextView dynamically into a RelativeLayout, with custom fonts, and sometimes the text appears underlined.
public void bouton_valide_ajout_texte(View v)
{
new_text_view.setText(((TextView) dialog.findViewById(R.id.edit_ajoute_texte)).getText());
RelativeLayout rl_newtext_1 = (RelativeLayout)findViewById(R.id.rl_newtext_1);
rl_newtext_1.addView(new_text_view);*/
TextView text_view = new TextView(this);
text_view.setText(((TextView) dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText());
ListView liste_view_police = (ListView) dialog_ajoute_texte.findViewById(R.id.list_view_dialog_polices);
text_view.setTextSize(TypedValue.COMPLEX_UNIT_SP,12);
text_view.setTypeface(listePolices.get_typeface(position_item_police));
text_view.setTextColor(Color.argb(255, 0, 0, 0));
text_view.clearComposingText();
container_calques.addView(text_view);
Object[] tab_calque = new Object[5];
tab_calque[0]="texte";
tab_calque[1]=text_view;
tab_calque[2]=12;
tab_calque[3]=0;
liste_calques.add(tab_calque);
calque_selectionne=liste_calques.size()-1;
text_view.setOnTouchListener(new TouchListener_calque(liste_calques.size()-1));
dialog_ajoute_texte.hide();
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ebm="http://schemas.android.com/apk/res-auto"
xmlns:sat="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="350dp"
android:layout_gravity="center"
android:id="#+id/rl_container_tshirt">
<ImageView
android:id="#+id/tshirt_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/tee_shirt_blanc">
</ImageView>
<RelativeLayout
android:id="#+id/container_calques"
android:layout_width="120dp"
android:layout_height="220dp"
android:layout_marginLeft="88dp"
android:layout_marginTop="85dp"
>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/layout_reglages_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
>
<SeekBar
android:id="#+id/seekbar_taille"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:max="40"
android:progress="20"
/>
<SeekBar
android:id="#+id/seekbar_rotation"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="50dp"
android:layout_alignParentLeft="true"
android:max="360"
android:progress="180"
/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Supprimer"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:onClick="bouton_supprimer_calque"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Couleur"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:layout_marginTop="40dp"
android:onClick="bouton_choisir_couleur"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Police"
android:layout_alignParentRight="true"
android:layout_marginRight="8dp"
android:layout_marginTop="80dp"
android:onClick="bouton_choisir_police"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="ajouter texte"
android:id="#+id/ajouter_calque"
android:onClick="bouton_ajoute_texte"/>
<Button
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="ajouter image"
android:id="#+id/ajouter_image"
android:onClick="bouton_ajoute_image"
android:layout_alignParentRight="true"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="enregistrer création dans galerie"
android:id="#+id/enregistrer_creation"
android:onClick="bouton_enregistrer_creation"
android:layout_below="#+id/ajouter_calque"
/>
</RelativeLayout>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.view.ext.SatelliteMenu
android:id="#+id/menu_flottant_gauche"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_margin="8dp"
sat:satelliteDistance="170dp"
sat:mainImage="#drawable/ic_launcher"
sat:totalSpacingDegree="90"
sat:closeOnClick="true"
sat:expandDuration="200"
/>
</FrameLayout>
</LinearLayout>
Solved
I replaced
text_view.setText(((TextView);
dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText());
By
text_view.setText(((EditText);
dialog_ajoute_texte.findViewById(R.id.edit_ajoute_texte)).getText().toString());
The possible underline could by the ListView as it puts a divider between its items. Look at this answer to get rid of the divider
Please make sure you don't have any inputType to your textview as follows
android:inputType="something"
Related
when I press the save button does not work after pressing it several time button is working sometimes first-time press is working sometimes after pressing moreover 10 times button is not working.Also i have toast messege to determine it is working or not the toast messege appear after pressing several time to the button.
binding.savebtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(Settringsactivity.this,"ok",Toast.LENGTH_LONG).show();
String status=binding.etStatus.getText().toString();
String username=binding.etUsername.getText().toString();
HashMap<String, Object> obj=new HashMap<>();
Toast.makeText(Settringsactivity.this,username,Toast.LENGTH_LONG).show();
obj.put("username",username);
obj.put("about",status);
if(name!=null) {
Toast.makeText(Settringsactivity.this,"Updated",Toast.LENGTH_LONG).show();
database.getReference().child("Users").child(name).updateChildren(obj);
}
}
});
Here is the xml code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/savebtn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:background="#color/white"
android:foregroundTint="#B11B1B"
tools:context=".Settringsactivity">
<ImageView
android:id="#+id/settingsbackarraow"
android:layout_width="30dp"
android:layout_height="30dp"
android:backgroundTint="#FFFFFF"
app:srcCompat="#android:drawable/checkbox_on_background" />
<LinearLayout
android:id="#+id/flinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/settingsbackarraow"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profileimage"
android:layout_width="120dp"
android:layout_height="120dp"
android:backgroundTint="#FFFFFF"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp"
android:src="#drawable/img" />
<ImageView
android:id="#+id/plus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/btn_plus" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="#100606" />
<EditText
android:id="#+id/etUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:textColor="#color/black"
android:hint="Enter your name"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="#100606" />
<EditText
android:id="#+id/etStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="About"
android:textColor="#color/black"
android:inputType="textPersonName" />
</LinearLayout>
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:elevation="15sp"
android:background="#1966FB"
android:layout_gravity="right"
android:text="Save" />
</LinearLayout>
</RelativeLayout>
i have spinner and 3 item video and photo and text and 4 button how i can show button if spinner select :
0
dow
favorite
Im trying to show a hidden button with spinner click
this is the cod
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_secim"
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="com.example.rdvanayan.yeni.Secim"
android:background="#android:color/holo_green_light">
<TextView
android:text="Bir seçim yapınız"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:textSize="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#000000"
android:background="#ffffff"
/>
<Button
android:text="KAYDET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/kad1"
android:textStyle="normal|bold|italic"
android:textSize="18sp"
android:layout_marginTop="22dp"
android:layout_below="#+id/editText7"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_alignParentEnd="true" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner"
android:layout_marginTop="12dp"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_below="#+id/kad1"
android:weightSum="1"
android:id="#+id/linearLayout2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/camera1"
android:layout_width="110dp"
android:layout_height="78dp"
android:layout_marginRight="100dp"
android:scaleType="centerInside"
android:visibility="invisible"
app:srcCompat="#drawable/camera" />
<ImageButton
android:layout_width="111dp"
android:layout_height="78dp"
app:srcCompat="#drawable/galll"
android:id="#+id/imageButton9"
android:scaleType="centerInside"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_alignParentEnd="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="URL İNDİR "
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button5"
android:layout_below="#+id/imageButton9"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_alignParentEnd="true" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<ImageButton
android:id="#+id/imageButton11"
android:layout_width="wrap_content"
android:layout_height="78dp"
android:visibility="invisible"
android:layout_marginRight="90dp"
android:onClick="dispatchTakeVideoIntent"
android:scaleType="centerInside"
app:srcCompat="#drawable/video_kamera" />
<ImageButton
android:layout_width="111dp"
android:layout_height="78dp"
app:srcCompat="#drawable/video_galeri"
android:id="#+id/imageButton12"
android:scaleType="centerInside"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_alignParentEnd="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="URL İNDİR "
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button4"
android:layout_below="#+id/imageButton9"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:layout_alignParentEnd="true" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText7"
android:hint="BAŞLIK"
android:visibility="invisible"
android:textStyle="normal|bold|italic"
android:textSize="20sp"
android:layout_below="#+id/spinner"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#000000"
android:background="#ffffff"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText8"
android:textSize="20dp"
android:hint="AÇIKLAMA"
android:textStyle="normal|bold|italic"
android:textColor="#000000"
android:background="#ffffff"
android:layout_below="#+id/editText7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="invisible"
android:layout_marginTop="11dp" />
<ImageView
android:id="#+id/igm"
android:layout_width="50dp"
android:layout_height="32dp"
app:srcCompat="#drawable/son"
android:layout_below="#+id/editText8"
android:layout_alignRight="#+id/editText8"
android:layout_alignEnd="#+id/editText8"
android:layout_marginRight="55dp"
android:layout_marginEnd="55dp" />
</RelativeLayout>
and this is spinner item
<string-array name="secim">
<item> YAZI </item>
<item> RESİM </item>
<item> VİDEO </item>
</string-array>
Any help would be appreciated.
You have to show and hide buttons on spinner selection in your Activity class. Set "OnItemSelectedListener" to your spinner, it will override few methods. In overridden "OnItemSelected" method hide the button like this:
yourButton.setVisibility(VISIBILTY.GONE);
I would like to add the previous answer as a comment. But the reputation is inadequate.
Actually it should be like this:
Use for hide: resimButonu.setVisibility(View.GONE);
or resimButonu.setVisibility(INVISIBLE);
use for show: resimButonu.setVisibility(View.VISIBLE); or resimButonu.setVisibility(VISIBLE);
thanks but i have 4 button and text i need :
if RESİM selected show 2 button
if * YAZI * selected show textbox
if *VİDEO * selected show 2 button
i have 4 button in app
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.secim, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
camerax.setVisibility(View.VISIBLE);
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
The image that is coming via a link is not getting set in the ImageView(Picasso). I have logged. I am getting the link but when I am calling
Picasso.with(SignAgreement.this).load(sign_url).into(img_set_sign);
the image is not set in the ImageView.
I am attaching the XML code and JAVA Code:-
signature.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e6e6e6">
<RelativeLayout
android:id="#+id/rltv_hdr"
android:layout_width="fill_parent"
android:layout_height="#dimen/capture_sign_LayoutHeight"
android:layout_alignParentTop="true"
android:background="#drawable/header_bg">
<TextView
android:id="#+id/search_header"
style="#style/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/dashboard"
android:textColor="#android:color/white"
android:textStyle="bold" />
<ImageButton
android:id="#+id/btn_back"
android:layout_width="#dimen/capture_sign_btn_back_LayoutWidth"
android:layout_height="#dimen/capture_sign_btn_back_LayoutHeight"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/capture_sign_btn_back_MarginLeft"
android:background="#drawable/back_button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rltv_agrmnt"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:layout_below="#+id/rltv_hdr"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="#dimen/capture_sign_rltv_agrmnt_MarginTop">
<ScrollView
android:id="#+id/scrl_vw_cstmr_agrmnt"
android:layout_width="fill_parent"
android:layout_height="#dimen/capture_sign_scrl_vw_cstmr_agrmnt_LayoutHeight"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/capture_sign_scrl_vw_cstmr_agrmnt_MarginTop"
android:background="#e6e6e6"
android:visibility="gone">
<TextView
android:id="#+id/txt_agrmnt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e6e6e6"
android:textColor="#000000" />
</ScrollView>
<WebView
android:id="#+id/wb_vw_invoice"
android:layout_width="fill_parent"
android:layout_height="250dp" />
<Button
android:id="#+id/btn_zoom"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="#dimen/capture_sign_btn_zoom_MarginBottom"
android:background="#android:color/darker_gray"
android:text="Zoom"
android:textColor="#android:color/holo_red_dark" />
</RelativeLayout>
<TextView
android:id="#+id/txt2"
android:layout_width="fill_parent"
android:layout_height="#dimen/capture_sign_txt2_LayoutHeight"
android:layout_alignLeft="#+id/rltv_agrmnt"
android:layout_alignRight="#+id/rltv_agrmnt"
android:layout_below="#+id/rltv_agrmnt"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/capture_sign_txt2_MarginTop"
android:background="#aaaaaa"
android:gravity="center"
android:text="Customer Signature"
android:textColor="#000000" />
<LinearLayout
android:id="#+id/ln_signature"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/img_btn_vw_clr"
android:layout_alignLeft="#+id/txt2"
android:layout_alignRight="#+id/txt2"
android:layout_below="#+id/txt2"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/capture_sign_ln_signature_MarginTop"
android:background="#ffffff"
android:clickable="true"
android:orientation="horizontal"
android:visibility="visible" />
<ImageView
android:id="#+id/img_set_sign"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/img_btn_vw_clr"
android:layout_alignLeft="#+id/txt2"
android:layout_alignRight="#+id/txt2"
android:layout_below="#+id/txt2"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/capture_sign_ln_signature_MarginTop"
android:background="#47ffcc"
android:orientation="horizontal"
android:visibility="gone" />
<ImageButton
android:id="#+id/img_btn_vw_clr"
android:layout_width="#dimen/capture_sign_img_btn_vw_clr_LayoutWidth"
android:layout_height="#dimen/capture_sign_img_btn_vw_clr_LayoutHeight"
android:layout_above="#+id/btn_decline"
android:layout_alignRight="#+id/ln_signature"
android:layout_marginTop="#dimen/capture_sign_img_btn_vw_clr_MarginTop"
android:background="#drawable/clear_signature" />
<Button
android:id="#+id/btn_decline"
android:layout_width="#dimen/capture_sign_btn_decline_LayoutWidth"
android:layout_height="#dimen/capture_sign_btn_decline_LayoutHeight"
android:layout_above="#+id/btn_paper_sign"
android:layout_alignRight="#+id/img_btn_vw_clr"
android:layout_marginTop="#dimen/capture_sign_btn_decline_MarginTop"
android:background="#ff4b25"
android:text="Decline" />
<Button
android:id="#+id/btn_accept"
android:layout_width="#dimen/capture_sign_btn_accept_LayoutWidth"
android:layout_height="#dimen/capture_sign_btn_accept_LayoutHeight"
android:layout_above="#+id/btn_paper_sign"
android:layout_alignBaseline="#+id/btn_decline"
android:layout_alignBottom="#+id/btn_decline"
android:layout_alignLeft="#+id/ln_signature"
android:background="#87b327"
android:text="Accept" />
<Button
android:id="#+id/btn_paper_sign"
android:layout_width="wrap_content"
android:layout_height="#dimen/capture_sign_btn_paper_sign_LayoutHeight"
android:layout_alignLeft="#+id/btn_accept"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/btn_decline"
android:layout_marginTop="5dp"
android:background="#87b327"
android:text="Signature via paper work" />
</RelativeLayout>
Signature.java
btn_yes.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
img_set_sign.setVisibility(View.VISIBLE);
mContent.setVisibility(View.GONE);
Picasso.with(Signature.this).load(sign_url).into(img_set_sign);
dialog.dismiss();
}
});
Please guide me with some guidelines why I can't set the image that is coming via URL that contains image to the imageview
I have an activity in which I have inflated another layout. OnClick of next destination I am getting inflated a new layout. Now I want to remove the inflated layout. So I want to access the linear layout of remove from inside inflated layout. How can I access this??
Layout looks like this :
I have achieved to inflate layout and remove the first destination from parent which is a part of parent layout. Now I want to do same with inflated destination layout. onClick of remove the inflated layout should get removed.
Next_destination layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_weight="1.00"
android:background="#android:color/white"
android:id="#+id/LinearAddedDestination">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="DESTINATION"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#drawable/shape"
android:gravity="right"
android:layout_gravity="center|right"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="80dp"
android:id="#+id/remove">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_clear_black_18dp"
android:layout_marginLeft="05dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="REMOVE"
android:layout_gravity="center"
android:layout_marginLeft="05dp"
android:textSize="14sp"
android:layout_marginRight="15dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="08dp"
android:background="#drawable/line2"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_place_black_48dp"
android:layout_marginTop="05dp"
android:layout_gravity="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/ic_chevron_right_black_24dp"
android:layout_marginEnd="10dp"
android:text="#string/Loc"
android:layout_gravity="center"
android:layout_marginTop="05dp"
android:textAppearance="#android:style/TextAppearance.Medium"
android:cursorVisible="false"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Street/Building/Place"
android:layout_marginStart="48dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginEnd="10dp"
android:hint="#string/LocationDetails"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginStart="48dp"
android:hint="#string/HouseDetails" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_person_black_48dp"
android:layout_marginTop="05dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="#string/additionalContact"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawableEnd="#drawable/ic_expand_more_black_24dp"
android:layout_marginTop="08dp"
android:layout_marginStart="05dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginEnd="50dp"
android:layout_gravity="center"
android:visibility="gone"
android:layout_marginTop="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Name"
android:layout_gravity="center"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Phone"
android:layout_gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/or"
android:layout_gravity="center"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="220dp"
android:layout_height="40dp"
android:background="#drawable/shape"
android:layout_gravity="center_horizontal">
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/phone2"
android:layout_gravity="center"
android:layout_marginStart="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/addFromContacts"
android:layout_gravity="center"
android:layout_marginStart="20dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginLeft="48dp"
android:hint="#string/contact1"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:background="#drawable/ic_description_black_48dp"
android:layout_marginTop="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginEnd="10dp"
android:hint="Instruction"
android:layout_gravity="center"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
Activity from on which the layout is inflated.
View newDestination;
ViewGroup parent;
nextDestination.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
removeDestination.setVisibility(View.VISIBLE);
newDestination = getLayoutInflater().inflate(
R.layout.next_destination_layout, addDestination, true);
}
});
removeDestination.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
parent = (ViewGroup)destination.getParent();
parent.removeView(destination);
}
});
How to achieve this?? Please help...
{ ll.removeView(view)// to remove particular view
ll.removeViewAt(position);// to remove view from particular position
}
I am trying to implement an onclick for the entire layout but it won't work.
Here is my function for my RelativeLayout:
public void updateRange(View v)
{
System.out.println("Hello!");
}
and here is my xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity"
android:background="#ffffffff"
android:id="#+id/xasdf"
android:onClick="updateRange">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/toptab"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/settingsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solutions"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/solutionsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mode"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/modeButton"
android:background="#fffdb64b" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/chartlayout"
android:layout_below="#+id/toptab"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView"
android:layout_weight="0.5"
android:background="#ffffffff"
android:fontFamily="monospace"
android:hint="y = ..." />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Graph"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.25"
android:id="#+id/button"
android:background="#ffd0d0d0"
android:onClick="drawGraph" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Table"
android:fontFamily="monospace"
android:layout_weight="0.25"
android:textAllCaps="false"
android:id="#+id/button2"
android:background="#ffd0d0d0" />
</LinearLayout>
</RelativeLayout>
Try adding the extra line below to your Relative Layout description:
...
android:onClick="updateRange"
android:clickable="true">