Using a Widget in Activity - android

it's me again :-)
Is there a way to use a widget (for home screen) in my own activites?
i think the homescreen is made with java, too?!
i do not want to change thinks in the widget, i still want to display them.
Regards
FLy

If you are looking to "re-use" a widget's layout and may be its base code, that is possible. I don't think it will be a good idea [or possible] to display a widget as an activity.
There are a lot of limitations in the number of view elements that can be used inside a widget. And again the way you will update a widget [RemoteViews] is actually very different from that of an Activity.
So in short, the answer would be a "NO".
Edit: This question has also been asked and answered a lot of times: difference between view and widget

Related

Android SeekBar within a homescreen Widget

I am looking to find a way to add a SeekBar to a homescreen widget. After reading this post on StackOverflow, I found that SeekBar's are not supported within a RemoteView, because it is a descendant of a ProgressBar. (Descendants of the accepted widgets are not supported)
Though, in my project, I am using Lars Werkman's HoloColorPicker found here. If you notice in the src, his OpacityBar (which is essentially a SeekBar) extends a View. Since all the accepted widgets (here) are descendants of View, I would think this would work. But alas, upon trying to load the homescreen widget with the OpacityBar, it shows up with the "Problem loading widget" response.
Does anyone know why this doesn't work? And know how to make it work?
Or does anyone know how to get a working SeekBar within a homescreen widget?
Thank you!
Since all the accepted widgets (here) are descendants of View, I would think this would work
I have no idea why you conclude that, as it it is a logical fallacy. According to your logic, since negative numbers are types of number, all numbers are negative.
Does anyone know why this doesn't work?
Because you cannot use custom Views, or anything else not supported by RemoteViews, in an app widget.
And know how to make it work? Or does anyone know how to get a working SeekBar within a homescreen widget?
Write your own home screen, and implement whatever you are trying to do with the SeekBar in that custom home screen.

Custom fonts for home screen widget TextView in android

the issue I face seems to have no solution and to be downright impossible to rectify, but I thought to ask here just in case I am missing something.
I need to display some text in an android widget using a non-system, non-standard font from assets folder.
Unfortunately, android does not allow extended view definitions in home screen widgets. Nor I can invoke a corresponding API method (setTypeface) from within the widget.
Does anyone know if there's any other alternative way to accomplish this?
(It seems quite natural to be able to customise text view appearance not only in the app but in widgets too, but it turns out to be impossible).
I'd appreciate any help on this.
Thank you...
Have you seen this link yet?
What is needed is to render the font onto a canvas, and then pass it
on to a bitmap and assign that to an imageview.
How to use a custom typeface in a widget?
By the way, you've asked 18 questions and have not accepted a single answer. I suggest you start accepting some or people will be less inclined to help you.

android: How can I implement first time tutorial like Go Launcher in my app?

Go Launcher have a nice first-time tutorial. it is very similar to Stock ICS first time run. I want to learn how to make the similar tutorial display at the first launch of my app. How can I implement this Transparent view (which interacts with screen objects) in my android app?
I was trying to do something similar using a transparent activity with a viewpager inside it. I wanted static 'tutorial' images that users could swipe through.
One of the answers to my question mentioned an interesting library (called ShowcaseView). It seems like it may be a good fit for your requirements as well.
https://github.com/Espiandev/ShowcaseView
You can either use a FrameLayout or RelativeLayout as root of your Activity/Fragment, and put your "first time" View upon content with a (almost) transparent background, or use another Activity/Fragment themed with a transluscent window. (like this)
I'd rather use an Activity/Fragment, but this is up to you!
I wrote little library That contains a simple component for making ​​a app tour. It`s very restricted to my case but maybe could be your case . Single LessonCardView Showed onstartactivity for the first time or on button click Any criticism ,help or advice will be appreciated. thanks https://github.com/dnocode/DnoLib
You can implement a first-time user guide with the Spotlight library by TakuSemba.
It is similar to the one shared above and it is still well-maintained (as of 2021).
https://github.com/TakuSemba/Spotlight

Android half visible activity

I would like to ask you guys/girls, if somebody have any idea how i can achieve a two activity transition in honeycomb, where the the not used activity will be visible a quarter of the original size and the other activity will be place to the center. Also i need to mention i used activities smaller then the screen resolution with dialog theme to get them to the center.
I looked into the ViewAnimator, ViewSwitcher, ViewFlipper, but i`m not sure if can do that. (Sure need to override this classes)
Somebody have any idea ?
You cannot have two activities "active" at the same time so showing any proportion of one activity and another and interacting with both is not possible, if you don't care about interacting with both simultaneously you might look at the SlidingDrawer class, a lot of people have customized that.
It is possible to kind of fake what you are asking by using two layouts and changing their proportions/position at runtime, for instance you could have a layout that takes up the entire screen, then on some event it could be re-positioned/sized and a hidden layout shown.
That is if I am understanding your question correctly.
Update
Also have you looked at fragments?

android: how to create multiply views screen?

I want to create an activity, which shows a question with 4 answers, and at the bottom of the screen i want to place a timer.
I have already found timer example, and i created a question with the answers. the problem that they are 2 different projects and activities, and i am looking for the best way to implement it. i think i can't show 2 activities on one screen, but i can show 2 views or shell i use the ViewGroup, or maybe to copy-paste one of the activities code to another ( its the easiest way but probably the most ugliest way to implement it).
please tell me what is the best way, that i will study and not to waste time to study all the ways and only then to choose one of them.
welcome to StackOverflow.
You are correct in that you cannot display two activities at once. You must instead look into how layouts work in Android by reading some tutorials on the Android developer guide.
For your layout, I would recommend using a LinearLayout with four TextView objects inside it containing the questions (and perhaps your EditText objects below them) as well as your timer. Make sure they are all inside a ScrollView so the software keyboard doesn't force it all to be squeezed up. This is how I would approach it, but I encourage you to read about how layouts work and use the XML resources.
The Notepad tutorial is an excellent way to get started with views and text entry, as well as using SQLite databases.

Categories

Resources