i am facing some problems with anable and disable traffic TYPE on the google map when OnMapReady.I have tow differents MAP_TYPE_NORMAL and MAP_TYPE_HYBRID.
what i want is to setOnclickListener when button is clicked.
my button code:
maptrafic.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(map.getMapType() == GoogleMap.MAP_TYPE_NORMAL || map.getMapType() == GoogleMap.MAP_TYPE_HYBRID){
map.setTrafficEnabled(true);
maptrafic.setImageResource(R.drawable.trafficmap_on);
}
else {
map.setTrafficEnabled(false);
maptrafic.setImageResource(R.drawable.trafficmap_off);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
});
also, i am working on googlemap using REST API i have successfuly create windowsInfoMarker but what i need is when map ready is to see the marker name only not all information like windowsInfoMarker but only Markers with name.
my MapActivity code shared from drive
MapActivity.java
my activity_map.xml
<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:layout_width="match_parent"
android:orientation="vertical"
android:id="#+id/drawer"
android:layout_height="match_parent"
tools:context=".activities.MapActivity">
<RelativeLayout
android:id="#+id/mapfloating"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--inclusion de la carte-->
<include layout="#layout/include_main_map" />
<!--fin inclusion de la carte-->
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="#+id/mainFloatingBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="25dp"
app:fab_labelStyle="#style/custom_floating_buttons"
android:layout_alignParentBottom="true"
app:fab_addButtonColorNormal="#color/blue">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/evennements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_events"
app:fab_title="Evennements"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/historiques"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_history"
app:fab_title="Historique"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/reglages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_setup"
app:fab_title="Reglages"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/aide_support"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_icon="#drawable/icon_support"
app:fab_title="Aide/Support"
android:background="#drawable/cerclebackground"
app:fab_colorNormal="#color/purple_500"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingPopUpLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:contentDescription="#string/app_name"
app:fab_colorDisabled="#color/white"
app:fab_colorNormal="#color/white"
app:fab_colorPressed="#color/blue"
app:fab_icon="#drawable/ic_menu_24" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingPopUpRight"
style="#style/custom_floating_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:contentDescription="#string/app_name"
app:fab_colorDisabled="#color/white"
app:fab_colorNormal="#color/white"
app:fab_colorPressed="#color/blue"
app:fab_icon="#drawable/ic_baseline_notifications_active_24" />
</RelativeLayout>
</RelativeLayout>
my include_mean_map
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/content_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true" />
<LinearLayout
android:id="#+id/zoomio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="#+id/fonctio"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="290dp"
android:layout_marginStart="9dp">
<ImageButton
android:id="#+id/zoom_in"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/zoom_in_selector"
android:layout_marginStart="4dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/zoom_out"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="4dp"
android:layout_marginTop="5dp"
android:src="#drawable/zoom_out_selector"
tools:ignore="ContentDescription,TouchTargetSizeCheck,SpeakableTextPresentCheck" />
</LinearLayout>
<LinearLayout
android:id="#+id/fonctio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="70dp"
android:layout_marginStart="9dp">
<ImageButton
android:id="#+id/showtails"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="#drawable/tail_active"
tools:ignore="ContentDescription,TouchTargetSizeCheck" />
<ImageButton
android:id="#+id/autozoom"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/icon2022"
android:layout_marginTop="5dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/geofences"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/geofence_active"
android:layout_marginTop="5dp"
tools:ignore="ContentDescription" />
<ImageButton
android:id="#+id/map_layer"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="#drawable/map_layer_change_icon_inactive"
tools:ignore="ContentDescription,TouchTargetSizeCheck" />
<ImageButton
android:id="#+id/map_trafic"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#drawable/grey_round_rect"
android:layout_marginTop="5dp"
android:src="#drawable/trafficmap_on"
tools:ignore="ContentDescription" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/loading_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:visibility="gone"
android:gravity="center">
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminate="true"
style="#style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/nodata_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:visibility="gone"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/noMapData"/>
</RelativeLayout>
</RelativeLayout>
if you have any idea please don't ready only i need help. any idea are welcome.
if you need more details juste ask i am online 24/7 each second.
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>
This question already has answers here:
Add positive button to Dialog
(3 answers)
Closed 5 years ago.
I am new in android app development. I am making a project in android-studio.I want to show pop up dialog whatever I have declared in xml file but OK button is not showing. If anyone knows about it, please share your answer.xml and java codes are below
image_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<!--<ImageView android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" android:src="YOUR IMAGE"/>-->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardViewbluetooth"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingTop="180dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth not enabled"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please enable bluetooth in settings and restart this application"
android:textStyle="bold"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="OK" android:onClick="dismissListener"/>
</LinearLayout>
</android.support.v7.widget.CardView></LinearLayout>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="litifer.awesome.game.litifer_carddemo.MainActivity"
>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView1"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
android:clickable="true"
app:cardBackgroundColor="#android:color/transparent"
android:background="#33FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageBeacon"
android:src="#drawable/beacon"
android:adjustViewBounds="true"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView1text"
android:text="Beacon Demo"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView2"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
android:clickable="true"
app:cardBackgroundColor="#android:color/transparent"
android:background="#33FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageWifi"
android:src="#drawable/wifi"
android:adjustViewBounds="true"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView2text"
android:text="Wifi Demo"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView3"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
android:clickable="true"
app:cardBackgroundColor="#android:color/transparent"
android:background="#33FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageCustomerReview"
android:src="#drawable/customerreview"
android:adjustViewBounds="true"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView3text"
android:text="CustomerReview Demo"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView4"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
android:clickable="true"
app:cardBackgroundColor="#android:color/transparent"
android:background="#33FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imagecardview"
android:src="#drawable/cardview"
android:adjustViewBounds="true"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView4text"
android:text="CardView Demo"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView5"
app:cardCornerRadius="5dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
app:cardElevation="0dp"
android:clickable="true"
app:cardBackgroundColor="#android:color/transparent"
android:background="#33FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imagedemo"
android:src="#drawable/demo"
android:adjustViewBounds="true"
android:layout_gravity="center"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cardView5text"
android:text="Test All Demo"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout> </ScrollView>
MainActivity.java
public class MainActivity extends AppCompatActivity {
private ImageView beacon,cardview,customerreview,demo,wifi;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
beacon = (ImageView)findViewById(R.id.imageBeacon);
beacon.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
} else {
if (!mBluetoothAdapter.isEnabled()) {
// Bluetooth is not enable :)
Dialog settingsDialog = new Dialog(MainActivity.this);
settingsDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(getLayoutInflater().inflate(R.layout.image_layout
, null));
settingsDialog.show();
}
}
}
});
}
}
try this
Dialog settingsDialog = new Dialog(this);
settingsDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(R.layout.image_layout);
settingsDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
settingsDialog.setCancelable(true);
settingsDialog.setTitle("Title...");
settingsDialog.show();
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 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">
I am trying to find a way to animate changing the alpha of a FrameLayout's foreground drawable, but i cant seem to find a way of doing it.
If someone could point me in the right direction as to how i should go about this i would be hugely grateful.
The relevant code is below:
XML layout file:
<com.bacon.corey.audiotimeshift.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="0dp"
sothree:shadowHeight="10dp"
sothree:paralaxOffset="100dp"
sothree:fadeColor="#android:color/transparent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:id="#+id/recordingListMainLayout"
android:foreground="#drawable/dim_shadow_shape_dark"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="0dp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainLayoutContainer"/>
<!--
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:padding="0dp"
android:layout_margin="0dp"
/>
-->
</LinearLayout>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionsMenu
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:gravity="right"
app:fab_addButtonColorNormal="#color/holo_red_light"
app:fab_addButtonColorPressed="#color/c16"
app:fab_addButtonPlusIconColor="#color/white"
app:fab_expandDirection="up"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c15"
app:fab_colorPressed="#color/c15"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/c8"
app:fab_colorPressed="#color/c8"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a1"
app:fab_colorPressed="#color/a1"
app:fab_size="mini"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textview_rounded_corner_background_fam"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option Four"
android:textAlignment="center"
android:padding="6dp"
android:fontFamily="sans-serif-medium"
/>
</FrameLayout>
<com.bacon.corey.audiotimeshift.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/a2"
app:fab_colorPressed="#color/a2"
app:fab_size="mini"
/>
</LinearLayout> </com.bacon.corey.audiotimeshift.FloatingActionsMenu>
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:textSize="16sp"
android:id="#+id/slideUpPanel"
>
</FrameLayout>
</com.bacon.corey.audiotimeshift.SlidingUpPanelLayout>
And the java code that i use to change the alpha of the foreground:
fabMain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
boolean expanded = fabMenu.toggle();
mainActivity.getDimShadowDrop().setForeground(getResources().getDrawable(R.drawable.dim_shadow_shape_light));
mainActivity.getDimShadowDrop().getForeground().setAlpha(180);
if (expanded){
((MainActivity)getActivity()).replaceFragment(new RecordFragment(), R.id.slideUpPanel, false);
slidingUpPanelLayout.expandPanel();
defaultColor = getResources().getColor(R.color.recordDefaultColor);
}
}
});
Instead of the typical way you do it with an Animation which is from 0 to 1 you use 0 to 255. Something like this will pulse the Foreground of a CardView.
public static void pulseForeground(CardView view, long duration) {
ObjectAnimator animator = ObjectAnimator.ofInt(view.getForeground(), "alpha", 0, 255);
animator.setDuration(duration);
animator.setStartDelay(20);
animator.setRepeatMode(Animation.REVERSE);
animator.setRepeatCount(Animation.INFINITE);
animator.start();
}