I want the set Button under the overlay to be able to just click only one button. I try setClickable in the overlay layout. Button can't click if not in overlay layout but I want only press Button if I want canclick.
Question: I want to know in which way I can do a tutorial that users will press Tutorials use the app
Open is APP
When Press Tutorials
I want Button can Click When Tooltip is appear
I set the press Button is
public void onClick(View v) {
if (v.getId() == R.id.button8) {
.
.
//This is Set Constraintlayout id in isoverlay
overlay.setVisibility(View.VISIBLE);
overlay.setClickable(true);
}
if (v.getId() == R.id.bisoverlay) {
if (c == 0) {
t1 = new Tooltip.Builder(b1)
.setText("FragButton")
.setGravity(Gravity.BOTTOM)
.show();
c++;
}
.
.
.
}
}
I want when tooltip is appear on Button ,Button can Click by overlay is not GONE
This XML Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout ...>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:id="#+id/moverlay"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--android:clickable="true"-->
<fragment
android:id="#+id/fragment1"
android:name="com.example.test.BlankFragment"
.../>
<Button
android:id="#+id/button8"
... />
<Button
android:id="#+id/button9"
... />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/isOverlay"
...
<Button
...
</android.support.constraint.ConstraintLayout>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
I use Fragment Button on Event in mainActivity
What Should id do?
(Sorry for English)
Ok now,I use FancyShowCaseview library .It's work! to overlay tutorial user guide,First time, I don't want to use library because want to pratice my android but I didn't have any idea. Thankyou and Sorry for english (I will pratice.)
Related
I have a fragment (fragment_1) which gets displayed when the main activity starts and displays a full screen layout (layout_1). Now i have added a button, clicking on which will start a new fragment (fragment_2)and replace the entire layout (layout_1) with my new layout (layout_2).
My first fragment (fragment_1) has a ScrollView as my root view.
<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:fitsSystemWindows="true"
android:background="#fff"
android:scrollbarSize="0dp"
android:id="#+id/scroll_main"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
....
</RelativeLayout>
</ScrollView>
Now i want to start a new fragment (fragment_2) on a button click and display another layout (layout_2) but i don't know how to do that.
My main activity had a frame layout like this
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/root_container">
And i used to set this as my default layout using
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
After this i start my first fragment and display the layout_1.
Now from fragment_1 i want to start fragment_2 and display the layout_2. I have read online articles and documentation where i can't find and solution regarding this. Pleas Note :" I don't want to simply replace a part of my layout_1 and replace it with my layout_2 rather i want my layout_1 totally gets replaced with layout_2 on a button click"
Replacing fragments seems like a job for the fragment manager.
This answer might help you Replacing a fragment with another fragment inside activity group
Im trying to find a method to freeze the activity state, but without success.
Im creating a game, and I want to add a pause button. When the user clicks, the activity should freeze with the components, and when click again, keep from where it was before. Is that possible to do that?
Please check the solution it can be helpful for u. As u want to freez the screen for sometime than u have to play with View Visibility.
For it u have to create the view like i have use the rlView in my below layout. Visible it when u want to freez the screen.And again when u want to remove it than set the visibility of view is gone..
We can manage the View visiblity like below:-
RelativeLayout rlView= (RelativeLayout) findViewById(R.id.rlView)
YOUR_BUTTON_CLICK.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(rlView.getVisibility()==View.VISIBLE)
{
rlView.setVisibility(View.GONE);
}
else {
rlView.setVisibility(View.VISIBLE);
}
}
});
}
Please check the layout:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
HERE IS YOUR WHOLE LAYOUT VIEW
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="#android:color/transparent"
>
</RelativeLayout>
</RelativeLayout>
I have 2 layouts which contain the same buttons
layout_1.xml
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_1"
android:text="button2"
android:background="#android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
and
layout_2.xml
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_1"
android:text="button2"
android:background="#android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Please assume these are all valid layouts etc.(I am just adding the relevant code.).
So in my fragment ,I inflate and use layout_1.xml in onCreateView.I want to toggle between the 2 scenes using button_1.
I can set the listener for button_1 in layout_1.xml during the onCreateView().
The problem is trying to set a listener on that button in the second view.i.e. the listener does not activate for the second scene(with layout_2.xml).And hence i canot toggle between the 2 scenes.Is there a way to achieve this?
It would actually appear that a proper way to do this would be to on the second scene you define an action to be performed as such:
mSecondScene.setEnterAction(new Runnable() {
#Override
public void run() {
((Button) mSecondScene.getSceneRoot().findViewById(R.id. button_1)).setOnClickListener( ... );
}
This will allow you to set your ClickListener on the View without the data binding to a generic click listener method. Then you can perform the Transition to the second scene and viola.
In general, it is not a good idea to have multiple views with the same id. This is what caused the confusion here.
Note: Below is the solution used by OP that was suitable for their specific needs:
One simple solution is to use the onClick attribute in the XML file. You can assign the same onClick method to multiple items. Like this:
And in your activity.java add this:
public void buttonClicked(View v){
Log.d("TAG","Button clicked!!"
// do stuff here
}
2nd option:
When you set a listener for one button with the id of button_1, it does not set the listener for both buttons, it only sets it for the first one. If you want to set the same listener for both, all you need to do is to assign these button different ids and then assign them the same listener.
This is what you should do:
Listener myListener = new Listener(){.. blah blah....};
((Button) findViewById(R.id.some_id)).setListerner(myListener);
((Button) findViewById(R.id.some_other_id)).setListerner(myListener);
3rd option:
findViewById(R.id.id_of_layout1).findViewById(R.id.button_1)
findViewById(R.id.id_of_layout2).findViewById(R.id.button_1)
in this case, you need add some id to your layout files, for example: layout_1.xml:
<RelativeLayout
android:id="+id/id_of_layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_1"
android:text="button2"
android:background="#android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
my textview display in emulator top..how to change into the bottom...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/tv">
<TextView
android:text="EmbDes Technologies"
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff000000"
android:textStyle="bold"
android:gravity="bottom"/>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/videoGrdVw"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
Although your question seems to be obscure, what i understand is that you want to align it to the bottom. Here is how you can do it:
Add the following property to your textview:
android:gravity="bottom"
Hope this helps. If it does, mark it as answered and do vote for it.
Regards.
well,
Button,TextView are all widget and subclasses from view
you can use textview as button easily ..
i.e. click responding:
TextView tt=(TextView)findViewById(R.id.tt1);
tt.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
//here I change background color when press on textviw element
v.setBackgroundColor(Color.RED);
}
});
I hope this helps you,
if not ask exactly what are you going to do..
good luck
Mohammed,
using the relative layout, align one view to the top with a bottom margin equal to the height of the bottom view and align the bottom view to the bottom of the relative layout...
can any one suggest how can i have a list of icons like browser icon,email icon and contacts icon upon clicking on those it should lead to android browser,email and contacts apps respectively...right now i have done it, upon clicking buttons. Now i want icons(with image and text) instead of buttons.
I think you just need to use something like this:
<LinearLayout android:orientation="vertical">
<ImageView android:src="#drawable/icon" android:onClick="launchApp" />
<TextView android:text="#string/icon_name" android:onClick="launchApp" />
</LinearLayout>
and in your code you should have the corresponding method:
public void launchApp(View view) {
// do something
}