Android :: Changing Tab Content With Intents Dynamically
Jul 21, 2009
I have a tabactivity with several tabs. They are all defined with intents. On one tab, I have an action that needs to bring me to another tab and with a specific data. I worked with Intents and I broadcast them to change the tab. For that I have no problem. But I am facing an issue as soon as I try to reset my tabs for the second time (when the application starts, my method does not fail while called for the second time it hrows an exception). The issue comes only If I call the clearAllTabs() method on TabHost. Here is the exception:..........................
View 2 Replies
Feb 2, 2010
Based on the limitations of RemoteViews, it looks to me that the appropriate way to get it actually drawn on the screen is to use an ImageView in the actual layout, then when it is updating, create a ShapeDrawable or two and draw them onto a newly created Bitmap. Then, set that Bitmap as the source of the ImageView. There is Something about that process that I'm just not grokking, though. The following is the code I tried to use to update the widget. I get nothing drawn on the screen at all. The ImageView has a placeholder image just set by its src property. When I don't run the code to update it to my drawing, the placeholder image stays in place. So, I know this code is doing something, just obviously not the right thing.
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
ShapeDrawable drawable = new ShapeDrawable(new ArcShape(0, 360));
drawable.getPaint().setColor(0xffff0000);
drawable.getPaint().setStrokeWidth(5.0f);
drawable.setIntrinsicWidth(100);
drawable.setIntrinsicHeight(100);
drawable.draw(canvas);
views.setImageViewBitmap(R.id.ImageView01, bitmap);
appWidgetManager.updateAppWidget(appWidgetId, views);
I knew it couldn't be that easy. So, am I even heading in the right direction? Update Ok, maybe that was too much information. The question I'm really trying to ask is this: If I want to draw shapes on a widget, should I use an ImageView and create a bitmap from my ShapeDrawable or is there more appropriate way to draw into a widget where it is constrained by RemoteViews?
View 7 Replies
View Related
Nov 24, 2010
Since I'm still just learning Android (and it appears Amazon says it'll be 2 months till I get the Hello, Android book) I'm still playing around with doing simple things. I have no problem getting an icon to display with the click of a button on my RelativeLayout using ImageView. The code for creating it is as follows:
private int mIconIdCounter = 1;
private ImageView addIcon(){
ImageView item = new ImageView(this);
item.setImageResource( R.drawable.tiles );
item.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
if( mIconIdCounter != 1 ){
params.addRule(RelativeLayout.RIGHT_OF, 1 );
}
item.setLayoutParams( params );
item.setId( mIconIdCounter );
++m_IconIdCounter;.......................
View 2 Replies
View Related
Jun 18, 2010
I'm trying to learn how to build apps for Android. The first simple app, which will become a component of a bigger app I hope to build, is to have a button on the screen where, when tapped, it adds something new to the view. For instance: Imagine a layout that only has a button:
[Create!]
When that button is pressed, the view gets a new row added to it:
[Create!]
A Something!..............
View 2 Replies
View Related
Aug 13, 2010
for(var myLine = 0; myLine < 100; myLine++)
document.getElementById("myDiv").innerHTML += "line " + myLine + "<br>";
...............
<div style="position:...etc; overflow:auto;" id="myDiv"></div>
this works without a glitch in every browser on all non mobile platforms. However... when this is implemented on iPhone (Safari) or Android (webkit) the div gets filled up with the text but no scrollbar is generated when the text runs past the height of the div and the user can't "push" the content down either. So effectively overflow is always "hidden" no matter what. I'm curious if there's some alternative approach that I'm overlooking or if this is just a bug I have no way to get around at the moment.
View 3 Replies
View Related
Jan 24, 2009
Is there any good example to show how a single compiled application could support both english and say germany.The aapt approach and Resource R.java approach seems to me that, we may need to have one binary for english and one for germany etc and so on. Like in J2ME, could we switch the language at runtime.
View 13 Replies
View Related
Nov 9, 2010
I have a textview in my XML layout file, but when I try to change its text value with code pragmatically (dynamically, depending on which button the user clicks) then the text of the textview doesn't change.
This is the code that I tried:
TextView userText = (TextView) findViewById(R.id.User);
userText.setText(bundle.getString("user"));
In debug mode, I can see that usertext has the changed text, but the change doesn't appear on my mobile window... I don't know why.
EDIT: SOLVED! it was a problem with my relative layout, text is out of the window!
View 1 Replies
View Related
Sep 24, 2010
I would like to change margin of my buttons in application. Suppose I have 5 buttons like this in a linear layout, one below d other. When I focus on a button, its width should increase (which I know how to handle) and at the same time, width should increase linearly towards both left and right. i.e. If the current width of the button is 250 with x co-ordinate as 50 (that means button's left is 50 and button's right is 300), when I focus on the button I should get x co-ordinate as 75 (left = 25 and right = 325). How to change the margin/x co-ordinate of the button?
View 1 Replies
View Related
Sep 29, 2010
I am trying to change linear layout or any other widget width or height dynamically but throwing exception.so how can I change the dimensions dynamically.....
View 1 Replies
View Related
Jun 5, 2009
I want to show an AlertDialog with one option that might change on every request. So for example at one time I want to show the option "add to contacts" while another time it should be "remove from contacts".
My code does work on the first time, however Android seems to cache the AlertDialog so that onCreateDialog is not executed next time. Therefore the option doesn't change anymore. Can I prevent this caching, or is there just another way of changing the option?
I am working with SDK 1.5 but using 1.1. Code...
View 5 Replies
View Related
Jun 10, 2010
I have added a menu to ListView Activity and wanted to allow the user to select the information that would be displayed in the ListView. So for example:
The ListView is populated in the onCreate method.
The user selects an option in the menu.
Upon the user making this selection the ListView would be populated with a different array.
Is onResume() executed after the menu is closed? I would test this but I am not currently home.
View 1 Replies
View Related
Nov 27, 2009
it is allowed to change the content of a file in the .apk archive at runtime? because the signature of the application will change.
View 2 Replies
View Related
Jul 24, 2010
I created an activity by using a layout written in a XML file. I would like, in response to some events, to change the content of this activity. I would like to show a VideoView over the content. In response to some other event, I may want to go back to the first content. Would it be possible to switch the content of the activity this way without running another activity (I have another technical difficult in doing that)? I tried using setContentView( videoView), and then switching back with setContentView(T.layout.main), but it seems that, when going back to the main layout, all my buttons and text boxes are created again as they were new. Would it be possible to go back to the last state of all the controls?
View 4 Replies
View Related
May 31, 2010
I would like to write a rather simple content application which displays a list of textual items (along with a small pic).I have a standard menu in which each menu item represents a different category of textual items (news, sports, leisure etc.).Pressing a menu item will display a list of textual items of this category.Now, having a separate ListActivity for each category seems like an overkill (or does it?)
Naturally, it makes much more sense to use one ListActivity and replace the data of its adapter when each category is loaded.My concern is when "back" is pressed. The adapter is loaded with items of the current category and now I need to display list of the previous category (and enable clicking on list items too)
Since I have only one activity - I thought of backup and load mechanism in onPause() and onResume() functions as well as making some distinction whether these function are invoked as a result of a "new" event (menu item selected) or by a "back" press.This seems very cumbersome for such a trivial usage.Am I missing something here?
View 1 Replies
View Related
May 4, 2010
Is it possible to disable title bar display dynamically after setting the content view by setting the NoTitlebar theme?
All the posts I have read told that any title bar changes we can make only before setContentView() call.
View 4 Replies
View Related
Apr 27, 2010
I am developing a calendar app, wherein i will using a service to display date in the application icon text itself. For Eg: If date is: 26 Apr 2010, then my application name in the phone menu will also show the same.So I am not understanding how to change the application's icon text dynamically through program.
View 2 Replies
View Related
Sep 17, 2010
Can anyone please help me? I have an 8gig micro SD card and none of my contacts, photos, songs or anything will save to it, they save to the phone instead and I don't know how to change it.I would just just the usb but my computer doesn't recognize the phone on my computer either.any help would be much appreciated!
View 13 Replies
View Related
Nov 7, 2009
I have some code that is creating and removing alarms, and which works great in Android 1.5 and 1.6 but breaks on the Android 2.0 AVD.The code that's giving this exception is: Code...
View 3 Replies
View Related
Aug 12, 2009
This may seem like a stupid question but I need to be sure. I was wondering if it was possible to pro-grammatically change the Content Provider used when making a query given a Content URI. The reason being I need to know if it's possible to force the Calendar/Contacts applications to read from a different database via a different Content Provider temporarily while my application is running, so that I can reuse those applications to display my own data. Since the Content URI s are hard coded in each of these applications the only way it might be possible is if we could somehow temporarily change the Content Provider used for a given URI. I know this probably isn't possible, I just need to show it isn't. Could someone confirm this can't be done?
View 2 Replies
View Related
Mar 1, 2010
I am having a hard time understanding content providers. In the notepad example and others, the content provider never even declares its CONTENT_URI anywhere inside itself, yet the docs say to publicly declare this. It's declared in a different class. So when an activity queries a content provider with a CONTENT_URI, how does Android know which one I want. I see no link between a content provider and its CONTENT_URI declared in another class.
I also don't how to think about intents and content providers. I know that you don't call an intent on a content provider. But an activity queries a content provider without an intent, and an activity has a mimetype attribute in the manifest that would seem to tie it to a content provider.
View 2 Replies
View Related
Mar 11, 2010
how can i create a custom content provider like contact content provider? i know how to create custom content providers but i want to integarte to device such a way that it canbe accessed by all application installed in that device.
View 3 Replies
View Related
Oct 30, 2010
I have an IntentService that broadcasts an Intent each time if finishes some work. Each broadcast Intent is identical except that it contains a Bundle with some result information from the IntentService. Evidently, having different data in the Bundle is not enough for Android to think it's a different Intent. If the IntentService broadcasts two of these Intents back-to-back, the second one is dropped as a duplicate.
I know I've read about this behavior in this forum in the past but I can't find in the documentation where this duplicate elimination logic is described in detail. Mostly, I just want to differentiate the Intents enough that they are not considered duplicates. Any pointers would be appreciated.
View 13 Replies
View Related
Mar 9, 2010
I've a succession of 2 Intent: Intent intent = new Intent(); intent.setClass(EntryPoint.this, MainClass.class); startActivity(intent);
And I'd like an animation (which is present in res/anim) occurs during the transition between these 2 Intents...
View 2 Replies
View Related
Aug 15, 2010
I have a auto-complete textbox in which the user makes a selection. From here I want to load a tabbed layout which is based on the user selection. The problem is I cant figure out a clean way to pass that selection to each of the tabs. At the moment I can pass an intent to the 'tabhost' activity and then pass to each child activity explicitly, however this just seems like messy iterative code to me! So basically how can I pass my intent data bundles to the tabs activities cleanly & efficiently! Psuedo code is also very welcome.
View 2 Replies
View Related
Aug 7, 2010
I am trying to create intents that will be set using alarmmanager. Currently, I can do this with one intent, add extra data to it (strings, but i send them as one string with a seperator), and everything works fine and goes off at the correct time. However, when I try to send multiple intents like this, they are overwritten and only one goes off at the correct time. How can i structure my intents so that they appear different to the alarmmanager (i think they are getting deleted when filterIntent() is run).
long story short- putExtra() makes all the intents look the same still... how can i make them look different so they wont get deleted (and keep track of them in case i want to delete a specific one)
View 2 Replies
View Related
Oct 27, 2010
I want to received the Android broadcast, is there a list of all intents?
View 2 Replies
View Related
Nov 17, 2010
I have searched and searched and I just can't get this code to work. I have a main.xml layout and a setting.xml. I have some values I would like the Settings.class to change in my main apps class.Three string to be exact. I have tried this simple test code in my main app class.
settings.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Settings.class);
startActivityForResult(intent, 0);}});
//Then a function
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
super.onActivityResult(requestCode, resultCode, intent);
Bundle extras = intent.getExtras();
String value = extras.getString("myKey");
if(value!=null){
Log.d("hmmm",value);}}}
In my settings.class I have the following
returnHome.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.putExtra("myKey", "YEAH");
setResult(RESULT_OK, intent);
finish();}});
Back in main app class it is not getting logged. Like I said I have three string in the main class that I want settings class to change and send back.
View 2 Replies
View Related
Apr 6, 2010
On the market, there's an application called App Protector, which seems to effectively block the launching of configured activities until a password is correctly provided. By default, it blocks access to itself (not very interesting), Settings, and a few others. I wrote my own app to launch settings (rather than doing so through the home screen) and App Protector continued to do the job it claims to do.
When an activity that is protected is started, App Protector's password input activity is shown instead. Once the correct password is provided, the activity that was started comes to the front.
First -- does anyone know how this app is able to get between the rest of the system and the activities it protects? I would like to do something along these lines in my own application as well. Perhaps this app is receiving a broadcast about other activities coming to the foreground, and when the foreground activity is protected, it forces itself to the foreground?
Second -- does anyone know how well this technique will stand up to attack? Are there other ways to circumvent, where start Activity(...) fails to? It seems that one could use adb to un install it, thus removing its protection easily, but if I pursue my plans here, the app will be a part of a device's firmware (which, I assume, offers some protection against its apps being installed?)
View 2 Replies
View Related
Aug 10, 2010
Found similar examples--not exactly what I need. I simply need to start messaging (SMS) and email intents from my app with their "to" fields already populated. So I need to send a number with the sms intent and an email address with the email intent.
View 1 Replies
View Related
Sep 19, 2010
Developers. I am a newbie to Android but a seasoned developer in UI, Java , and ECLIPSE. I am trying to do something I believe is very simple yet I am struggling. I have two tabs, A & B. I want to put an Activity in each tab. I want to have the 'B' Activity live inside 'A' so I can access it within 'A'. 'A' has a clock and every second that passes I need to update information in 'B', even if 'A' is not currently shown. I put 'B' into the 2nd tab as follows:TabSpec mapInfo=tabs.newTabSpec("tag3"); Intent intent = new Intent(this, MathleteMapActivity.class)mapInfo.setContent(intent); mapInfo.setIndicator("Course Map");tabs.addTab(mapInfo); I am totally confused on how to get the "MathleteMapActivity" Activity from the Intent 'intent'. There appears no way to do this. Can anyone please recommend a cleaner way to do this knowing what I am trying to do?
View 4 Replies
View Related