One layout as background of other layout - android

I want to set My Loading layout in the front of mainview layout and make it transparent.
I made it like this:
So, the question is: How to make mainView disabled (not clickable) While loadingView is visible.....?

ProgressDialog ProgressDialog = new ProgressDialog(this);
ProgressDialog.setMessage("");
ProgressDialog.setCancelable(true);
ProgressDialog.show();

Try to set the mainview's corresponding layout not to be clickable, by using the setClickable() method.
Set it back to true when loading ends.
It would be useful if you post some code.
Also, take a look to this Android Layout make all children's not clickable
it's about the layout's children, but i believe it is also helpful

If your loadingView is covering the mainView, you can either make it (loadingView) clickable or add a onClickListener to it.
Now the clicks won't be taken by the mainView and its children.
In terms of code, you can either write:
loadingView.setClickable(true);
Or set click listener like:
loadingView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// do something here if you want
}
});

Related

How to Implement EditText in ListView like a Tree view in Android

I am working with android development and want to implement edittext in listview such like that in picture. now want to add this kind of implementation. is there any way to do exactly this thing or any library which is doing this work.any kind of help will be appreciated and thanks an advance.
It's pretty simple. I recommend you not to use listview to implement that. Just use LinearLayout with vertical orientation, and add each field when the "Add More" button item clicked.
LinearLayout parentLayout = (LinearLayout) findViewById(R.id.parent_layout); //make sure you have set vertical orientation attribute on your xml
TextView addMoreText = new TextView(context);
addMoreText.setText("Add More");
addMoreText.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
EditText editTextItem = new EditText(context);
parentLayout.addView(editTextItem, 0);
}
});
parentLayout.addView(addMoreText);
Note that the code above is just global picture of how to solve your problem. For implementation with close or add button on the right side, you may create custom view that holds EditText, ImageView based your own.

Adding editText on button click

I have a layout (activity_main.xml) that has some TextView and EditText elements and a button.
I have some stuff happen when the button is clicked, but I want to add a new EditText element directly below and existing element after the button has been clicked.
How can I make this happen please?
Usually i just play around with the Visibility of the elements. Example:
on OnCreate: EditText1.setVisibility(GONE);
and then on your OnClickListener Implementation:
private OnClickListener onShow = new OnClickListener() {
public void onClick(View v) {
EditText1.setVisibility(VISIBLE);
}
}
This will hide your EditText (or whatever element you want) in the creation of the activity, and then show them again when you pressed the button.
The above mentioned method is easier and it seems suffice enough for most of my projects. However, if we really want to add elements dynamically, there is a way.
We can basically add any element dynamically to our xml layout. But we need an element (container) in our xml layout for holding our added element later. Example, we use an empty LinearLayout with android:id="#+id/container". With this in mind, it means we can build everything dynamically from scratch and setContentView(ourView), where ourView is the root element with other child elements added.
Example:
EditText newElement = new EditText(this);
newElement.setLayoutParams(params);
LinearLayout container = (LinearLayout)findViewById(R.id.container);
container.addView(newElement);
Note: This is just a pseudocode and not a complete code.

Is there a way to extend AlertDialog and then totally take control of its appearance?

I'm looking at the documentation here:
http://developer.android.com/guide/topics/ui/dialogs.html#PassingEvents
And all their examples seem to overlook the developer's potential desire to totally alter the appearance and/or positioning of the OK | Cancel buttons.
I feel like the solution with the DialogFragment comes close, but still there's no obvious way for me to define what View in my activity should BE the OK button, so that I can easily attach the callback to it.
What am I missing? Or is it really not possible to manipulate the appearance and position of the buttons in anything that extends AlertDialog or DialogFragment?
You can use Dialog and add your own custom layout to it and control the appearance of every view in it. Here is an example how you can do this :
final Dialog alert = new Dialog(FingerPaintActivity.this, android.R.style.Theme_Light_Panel);
alert.requestWindowFeature(Window.FEATURE_NO_TITLE); // no title
alert.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation; // this is used for custom animation when dialog is showing and hiding
alert.setContentView(getLayoutInflater().inflate(R.layout.stamps, null)); // here is your custom layout
alert.getWindow().setLayout(width-50, (height-100)); // set height / width
and you can use set listeners to your views (for example a button) like this :
Button myOkBtn = (Button) alert.findViewById(R.id.myOkBtn);
myOkBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});

Making custom android views "tappable" with a feedback highlight

I'm using a custom view expanded from a XML layout in a horizontal scroll view as a sort of horizontal image list but I'm not sure how to get them to appear clickable/tappable (ie they highlight when tapped) or how to capture these events. I think I've tried setOnClickHandler without it working. I'm also trying to get a simple TextView to do the same. I've also tried setting android:clickable="true" but that hasn't helped either. Any ideas?
To take care of the visual feedback use an xml Selector, and set it as the View's background.
To handle click events use
mView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//your code here
}
});

how to zoom-in interface? Android development

In my Android application, I have an activity with three layouts: A left layout, a middle layout, and a right layout.
The right layout is the main one. I want the right layout to zoom into fullscreen when I click a button. If you have the specific code,it's better.
Thanks very much!
If I got your question right:
Your button's OnClickListener should look like something like this:
OnClickListener listener = OnClickListener() {
public void onClick(View v){
findViewById(R.id.left_layout).setVisibility(View.INVISIBLE);
findViewById(R.id.center_layout).setVisibility(View.INVISIBLE);
};
This by itself will not get your right layout to fullscreen. You'll need to add something the below to your right layout for it to "auto fullscreen":
android:layout_width = "0dp";
android:layout_weight = "1";
if you don't do that, you'll have to resize the right layout from the "listener" above.
Hmm, the question is vague, but if I understand correctly, what you want to do is hide the left and center layouts when a button is clicked, so that the right layout becomes full-screen?
Without more details, it's not easy to give you a more precise answer (please post your current layout), but I would do something like:
// this code in your Activity:
// this method is bound to button onCLick (android:onClick="clickButton")
public void clickButton(View view) {
findViewById(R.id.left_layout).setVisibility(View.INVISIBLE);
findViewById(R.id.center_layout).setVisibility(View.INVISIBLE);
}
And to revert back to a 3-layout display, you do the opposite (View.VISIBLE)

Categories

Resources