how could i get an image and a text from the Internet and made a button for my android application dynamically?And draw them in th position i want.
i.e by Java code
thinks
Download the image and the text, then:
button.setText(downloadedText);
button.setBackgroundDrawable(drawable);
You'll have to create a Drawable from the image, which you can probably do using Drawable#createFromStream.
Drawing the button in the position you want is no different from a normal button. Just declare it in your XML (possible set to Visibility.GONE at first), get a reference to it using View.findViewById and then do the above operations on it.
Related
I need to add hint text for next and previous Image View in android app,how can i do it.There is no attribute like hint in image view.
I have 2 images and need to show hint when user tries to click on those images
Starting with Android API 14+, there is an event for hovering. You can do,
view.setOnHoverListener(...)
and listen for MotionEvents such as ACTION_HOVER_ENTER and ACTION_HOVER_EXIT, instead of onLongClick.
I have a Button (btn). Is set the Button's style using a drawable:
btn.setBackgroundResource(R.drawable.mybtn_style);
This Button has some text. In some occasions I want to use an image instead of text.
Using the following:
if (useImagesinButtons==true){
btn.setBackgroundResource(R.drawable.ic_myImage);
btn.setText("");
}
replaces the style with the image (myImage).
But I don't want to change the overall style of the Button. I just want to set an image instead of text. I want to do that programmatically.
Could I change the drawable's background image before calling
btn.setBackgroundResource(R.drawable.mybtn_style);
if (useImagesinButtons==true){
btn.setBackgroundResource(R.drawable.ic_myImage);
}
else{
btn.setBackgroundResource(R.drawable.mybtn_style);
}
->First set the button background in the XML file using " android:background" attribute.
-> then when ever you want text on button just set the text on button.
You can't change a style programmatically. However, you can create two different button instances for the two specific case you have. One text-only button and one with an image. Ofcourse you will be using one of the two at a time. Whenever the condition changes, you remove/add buttons.
i want to create a home screen application where the applications looks like carousel , and i am able to do it . The problem i am facing is that in my application only the applications icon are getting displayed the text is missing in it , where as my requirement is that i want to both the icon and text to be displayed together.
my application displays same as the above showing image.
i want text to be combined with it as above image.
please help me.
Thanks
datta
So the simplest thing to do would be to create a Compound Control. This compound control would essentially be a LinearLayout with both and ImageView and a TextView in it. Then, where ever you use a CarouselImageView in your code, just use your new compound control instead.
I have one screen with some image buttons and image view. when user click on these buttons or image view i need to show selected effect not replace any image instead of these. only selected dark shade effect on button or imageview same as iphone. How it's possible ?
i have not any selected image source , i checked these code ...
http://developer.android.com/reference/android/widget/ImageButton.html
But here we set another image on pressed event.
Anyone know any property of android to directly set select dark shadow
effect without image ?
Please anyone suggest how its possible ?
Thanks
you can use setAlpha method of imageView class to do this.
imgView.setAlpha(90);
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
Thats the link for adding images to show different state of buttons. You create a xml file for this and set this file as the background for the button.
I have a program that I'm writing in Android using Eclipse. It has an array of buttons (4x4).
I would like to have the buttons contain a user defined image (perhaps some filled circles).
How do I go about doing this?
Thanks
Mike
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton
Should be straight forward enough to follow.. if the image is chosen by the uesr, you will just have to change the image path on a button press or something similar