Android :: Changing Widget Layout Programmatically
Dec 7, 2009
Let's say that I have two layouts for a widget: Layout1 and Layout2. The default for the widget is Layout1, but I allow the user to choose which layout they want the widget to be. So if the user changes to Layout2, how do I programmatically change the layout to Layout2? There isn't a setContentView method for widgets like there is for Activities.
View 2 Replies
Apr 28, 2010
I have this really annoying problem:In my widget, i would like to change the background by code. I noticed on the Google doc than I can easily change the background of an Imageview: remoteViews.setImageViewResource (R.id.my_iv, R.drawable.my_bg);Ok, too easy, i want to change now the Linear layout.. What I read about the remoteview id that I can change a Bitmap, Int, Bool, String, etc. but not a drawable. So i guess i cannot use:remoteViews. set Bitmap (R.id.my_ll, "setBackgroundDrawable",BitmapFactory.decodeResource(context.get Resources(), R.drawablemy_bg));I am totally disapointed and tried a last idea: views.setInt (R.id. my_ ll,"setBackground Resource" ,R.drawable.my_bg);But The logcat told me: android. widget. Remote Views $Action Exception: view: android. widget.LinearLayout can't use method with RemoteViews:setBackgroundResource(int)I am totally lost and I really don't know what to do.
View 1 Replies
View Related
Nov 21, 2010
I can write a widget with a Button or ImageButton and assign a StateDrawable as background or sourcein order to make an effect when you click it. Besides that I have problems with the side of each button, my main problem is this: how do I change the StateDrawable if I want to change the image of the button from the AppWidgetProvider but still want to preserve the click effect like a StateDrawable. The power control widget in Android does things like that.
View 2 Replies
View Related
Sep 19, 2010
I want to change the network signal strength programmatic-ally in android..Even though signal is full i want to make it 50% or even 0%. Friends is it possible..?
View 1 Replies
View Related
May 30, 2010
I am trying to improve the layout for my game. The problem is that while I can create a good layout for one android phone, it doesn't work for another, ie the trackball for MyTouch is on the right side (landscape mode), but for the MyCliq, the DPad is on the left side. Is there a way to programmatically set the layout based on which phone it is?
View 2 Replies
View Related
Jun 14, 2010
I know that unfortunately detecting and changing programmatically data connection (GPRS/UMTS) on vanilla Android is not possible, and the common workaround is to edit APN settings. This is hardly a nice solution. However on my device (Xperia X10) I have an additional setting near "data roaming", that allows to enable or disable MMS and data. I suppose that this is a personalization made by Sony Ericsson, and maybe even other vendors have something like this. Is there a way to access this setting?
View 3 Replies
View Related
Sep 10, 2010
I am trying to change the locale programmatically on Android. The code I have below works fine on the Incredible(2.2) and Droid(2.2). However, it doesn't on the DroidX(2.1 Update 1) Anyone here have encountered similar problem ?? Any insight would be helpful.
public void overrideLocale(String languageToLoad) {
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, null);
Intent intent = new Intent(this, ActivityB.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); }
View 1 Replies
View Related
Jul 7, 2010
I've created an Activity subclass called CustomTitlebarActivity. Essentially, each main activity in my app will have a custom titlebar with many common features such as a Home button, a title, a search button, etc. In my current implementation, I am still explicitly using an include statement in the layout XML for each CustomTitlebarActivity: <include layout="@layout/titlebar" />
It seems natural that I should be able to do this within CustomTitlebarActivity. I have two questions: What code can replace this include tag, and where should I put the code? (My first instinct would be to put it in CustomTitlebarActivity's setContentView method.)
On a related note, I would appreciate insight into better ways to reuse android UI code (even if, per se, the titlebars need to vary slightly between activities.)
View 1 Replies
View Related
Mar 9, 2010
if it's possible in Android to programatically change the phone internet settings (proxies also), email settings and other similar? Is there some kind of registry? and what about getting the lost/received/etc calls? is it possible to get that info?
View 1 Replies
View Related
Nov 9, 2010
I have ScrollView with RelativeLayout as a child of ScrollView. I am trying through JAVA code to set Layout_Gravity to CENTER so my RelativeLayout is centered (horizontally and vertically) in the middle of ScrollView (that covers whole screen).This works fine in XML and produces desired result, but when I try to do this programmatically, it seems there is no way to set Layout_Gravity of RelativeLayout. I tried using LayoutParams, but couldn't find anything there that would help me to center RelativeLayout in the middle. So, am I missing something or this simply can't be done?
View 7 Replies
View Related
Jul 8, 2010
I am trying to add TextViews to my xml-defined layout in code. I have a xml-sheet, where a lot of Views are defined. But I have to add some views in code, so a create a LinearLayout in the xml-sheet:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="@+id/info"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
And in this layout, I like to add my TextView:......
View 2 Replies
View Related
Apr 5, 2010
I was wondering if it were possible to dynamically create an XML layout file to be displayed to the user. The idea would be to be able to retrieve a layout file from a central server, which could display this dynamic, server driven GUI.
View 2 Replies
View Related
Sep 2, 2009
I'm programmatically adding views to a LinearLayout inside a ScrollView and i'm running into some issues setting margins and padding etc for child views of the LinearLayout.
i've tried child.setPadding() and adding the view with a MarginLayoutParams set up right, but the child view still fills the parent width.
what is the correct way to programmatically set the parameters which are set statically by layout_marginLeft, layout_marginRight, etc?
View 9 Replies
View Related
Apr 2, 2010
Im using an inflater inside an adapter for my listview. I need to add in a different button depending in the state of the data for each row, so Im thinking I need to do this programmatically, but how do I make sure its inserted into the correct place inside the layout?
View 1 Replies
View Related
Oct 7, 2010
I'm unable to change the layout_gravity of a Button programmatically, does anybody know how to do this?The gravity attribute is easily changed using Button.gravity(), Ie it changes the gravity of the text inside the button I cannot change the gravity of the button itself. I also cannot seem to find this in any of the layout params contructors.
View 2 Replies
View Related
Jun 17, 2010
I have defined an List View in xml as below
Code...
And i need to re-define the layout margin upon some result in my programe ,how i can achieve this
View 1 Replies
View Related
Aug 19, 2010
My application will have two layouts, one for large screens and one for normal. For testing I'm working with one phone (800x480 240dpi) and one tablet (1024x600 240dpi) but both are detected as large screen hdpi and long aspect ratio, so I'm not able to assign different layouts.
The only approach I think that can work is to create layout-large and layout-normal, get the resolution and programmatically set the layout folder. Is that possible?
View 6 Replies
View Related
Sep 12, 2010
i've got this simple layout in a file derived from Activity
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" > <ImageView android:id="@+id/photo" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </ScrollView>
i'd like to change the imageview contents dynamically. which method do i need to overload - again this class is derived from Activity.
View 2 Replies
View Related
Jan 14, 2010
I am trying to modify the design of Spinner widget. I can change the background, but I can't find a way to change the arrow icon on the right side. Is there a way to do it?
View 3 Replies
View Related
Nov 8, 2010
I'm not looking for exact code here, just a direction on what to look for and what I should be reading about so I can figure this out. I have a layout that I would like to remain static, with only the listview changing depending on what's selected from the list. I've reloaded data in the list, but I would like the fancy transition animations between choices, and would like the app to go to the previous menu when pressing back.
Someone suggested using a viewswitcher, which seems like it'd be great, but I am still unsure about how to fill a listview in a layout with a regular row layout, then on selection do an animated transition to a custom row. Also, it seems the viewswitcher is limited to two views, so it may be a limitation when I want to go a few menus deeper. Preferably, I'd like to put each menu in it's own class so that I can handle filling it in that class, if possible...
View 1 Replies
View Related
Nov 11, 2010
I want to know how to center a GUI widget programmatically. I am using a LinearLayout.
View 1 Replies
View Related
Sep 17, 2010
I want to change the screen brightness programmatically in android.
WindowManager.LayoutParams lp = getWindow().getAttributes();
float brightness=1.0f;
lp.screenBrightness = brightness;
getWindow().setAttributes(lp);
But this sample code works on cutcake, not on latest versions. I am using latest version of SDK. How can I do it?
View 2 Replies
View Related
Aug 11, 2010
I know it's possible, but I can't figure out a way to trigger an update of my widget from the main activity. Isn't there some general intent I can broadcast?
View 1 Replies
View Related
Nov 8, 2010
I see there is a TextAppearanceSpan available but no examples on usage. I just want to make the text bold and leave everything else unchanged - is there perhaps a simpler way to do this programmatically?
View 1 Replies
View Related
Jun 8, 2009
I am having a bit of trouble with my current application. With a button at the beginning of my app, I send out Intents for two activities, one gets a camera object, and starts a preview screen. On top of that, in a separate layout, there is an activity with a translucent view, which shows a resource image (the user is trying to get the image he is actually taking to align with the translucent image) and a couple of textviews displaying a target phone orientation as well as the user's current phone orientation.
when I update the text value of one of my text views in my onSensorChanged() field, the system constantly reallocates 1.22MB and garbage collects it. I can only assume that this is because it is redrawing the entire layout with the translucent image and the text fields, because if I remove the view containing the translucent image from the layout, my text field updates 10x quicker and I don't have ridiculous heap growing / garbage collecting. I am wondering how to go about getting the text fields to update without redrawing the entire surface. I am very new to UI design, and this code was written by someone else before I took over the project, so I don't understand much of what is going on in the custom view he wrote to take care of the translucent image -- called MyView. I will post the code for the layout as well as the MyView code below.................................
View 4 Replies
View Related
Oct 28, 2010
I have in many of my screens that re mostly constructed of LinearLayouts a FrameLayout that should take up the bottom leftovers of the screen (using layout_height="0dp" layout_weight="1") inside it there's a FrameLayout with gradients background and in it's middle with some padding lies a button with some text, naturally i need the text and onClicked properties to me different from screen to screen. I considered using <include > tag for the above compound in my layouts, but as far as i can see i can't really change (at least not in xml) the button text and callback, is that really so?
View 2 Replies
View Related
Jul 16, 2010
What's the best way to change width/height of a widget (I mean, a UI widget, subclass of android.view.View) programmatically?
Doing something like this works, but it doesn't seem quite right:
CODE:....................
View 2 Replies
View Related
Jul 21, 2009
In ApiDemo, there is a progressBar demo. It creates a horizontal progress bar with a xml.
<ProgressBar android:id="@+id/progress_horizontal" style="?android:attr/progressBarStyleHorizontal" android:layout_width="200dip" android:layout_height="wrap_content" android:max="100" android:progress="50" android:secondaryProgress="75" />
But how to create one programmatically? If just new ProgressBar(fContext), it is Default ProgressBar style.
View 2 Replies
View Related
Apr 28, 2010
I'd like to programmatically move between images in the Gallery widget, with animation.
I can change the currently displaying image using the setSelection(int position) method, however that does not animate. Then there's setSelection(int position, bool animate) but the extra boolean on the end there doesn't appear to do anything.
In the source of Gallery it appears that it can handle DPAD key-presses, so a work-around I thought of was to fake the key-presses. Eg.
dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_LEFT))
However I can't get this working for some reason. Anyone tried this?
I notice three of the widget's methods I'd love to use moveNext(), movePrevious() and scrollToChild() are all private and unusable.
Does anyone know how I might be able to do this?
View 5 Replies
View Related
Sep 1, 2010
I recently updated to the 2.1 ROM update. I was wondering if there is anyway to change icons and maybe learn how to to customize my layout.
View 4 Replies
View Related