Android :: ViewFlipper Not Working Inside A Class Which Extends LinearLayout / Reason Of It?

Apr 22, 2010

When I tried to create a ViewFlipper inside a class which extends LinearLayout, its throwing an exception

"java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()".

I am creating the ViewFlipper using,

ViewFlipper flipper = new ViewFlipper(ctContext);

But when I create the ViewFlipper in a class which extends Activity, its working normally. What may the reason?

Android :: ViewFlipper not working inside a class which extends LinearLayout / reason of it?


Android :: TextView Inside LinearLayout Stretches The LinearLayout

Aug 21, 2010

If I have 2 LinearLayouts split %50/%50 everything is fine. Weights are 1 and 1. As soon as I add a TextView inside the top LinearLayout, it stretches that layout. I use "wrap_content" as the documentation says I should when it comes to weights. As you can see the red and green should be split evenly and text on grey background should be inside red box.

Here is the code:..............

Now if I switch to "fill parent" as follows it actually works but it creates another problem. Here is the code (so far so good):

So looking at above we were forced to use "fill_parent" and we would think like we fixed the problem but here is the problem if we are using "fill_parent" (I took out the textview just to show the problem, textview doesnt make the problem go away anyways):

As you can see I assign the weights 3 (top red) and 2 (bottom green) but what actually happens is they get flipped: The red becomes 2 and bottom becomes 3. Just measure the pixels too see.

Here are the results of the 3 codes: http://imgur.com/iVt8g.jpg

View 4 Replies View Related

Android :: ListView Inside LinearLayout Inside ScrollView

Jul 7, 2009

So I've been extremely frustrated by this for a long time now.I've posted before, but can't seem to find a good solution. My goal is to have something pretty much exactly like the installed application details page in the Android Market.I need a list of items displayed along with other content above the list, and would like the content above to scroll up along with the list (exactly like the application details does for the "My Review" and other descriptive info).Due to responses to my previous posts, I came to believe that it really wasn't possible to do this with a ListView.So rather than using a ListView, I refactored my code to use a simple LinearLayout and add individual View items to the list, thinking I could just set each View as clickable and add an OnClickListener to each View in the LinearLayout.That's not working at all though, and now I'm getting even more frustrated.If someone can help me get the OnClickListener working, then I think it'll work, but I do need a separator for the LinearLayout.How do I add a separator like the one used for ListView to my LinearLayout?

View 12 Replies View Related

Android :: Can I Set A ContentView Inside Of A ViewFlipper

Sep 1, 2010

I have a ViewFlipper that contains Layouts.

Is there a way I can hook up a Class to manage each layout seperately?

Kind of like setContentView(R.layout.main); but I'm not sure how to reference the 3 different layouts in code...

View 1 Replies View Related

Android :: Example To Use Class SingleLaunchActivityTestCase <T Extends Activity>?

Aug 2, 2010

I am quite new to Android and Java
I am looking for example of how to use this class:

SingleLaunchActivityTestCase

Till now I am using class InstrumentationTestCase but the problem is that for each launched test case Android calling onSetup() and TearDown()

View 2 Replies View Related

Android :: Can Use GetCacheDir Only In Class That Extends Activity?

Jun 19, 2010

Can I use getCacheDir() only in a class that extends Activity? I would like to use it in an AsyncTask so that I can do the time intensive cache file saving in it.

View 1 Replies View Related

Android :: When Extends MapActivity Class It Shows An Error

Feb 17, 2010

When i extends the MapActivity class it shows an error.

error is: cant resolved datatype. why?

How to add a maps.jar in my project?

View 1 Replies View Related

Android :: Place An ImageView In A Class That Extends View?

Sep 30, 2010

Is it possible to place an imageView in a class that extends View in android?
If possible please give me a sample code.

View 1 Replies View Related

Android :: Simple Program - Class Extends Activity At Startup

Oct 1, 2010

I have a simple activity program in android. Basically the class just extends Activity.
But when I start it I get a ClassCastException in the constructor of my class. I don't even have a constructor defined, so it must be in the constructor of the superclass which is Activity. Unfortunately the debugger doesn't give any detailed information on what class it is trying to cast. Here is the stacktrace:

Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread$PackageInfo.makeApplication(boolean, Instrumentation) line: 649
ActivityThread.handleBindApplication(ActivityThread$AppBindData) line: 4232
ActivityThread.access$3000(ActivityThread, ActivityThread$AppBindData) line: 125
ActivityThread$H.handleMessage(Message) line: 2071
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]

And when I look into this runtimeexception I get:

detailMessage "Unable to instantiate application com.test.MyApp: java.lang.ClassCastException: com.test.MyApp" (id=830067694464)
The only code is:
package com.test;
import android.app.Activity;
public class MyApp extends Activity {
}

View 3 Replies View Related

Android : Unable To Use Shared Preference Within Class Extends View

Jul 28, 2010

I am getting an error , when I try to access the shared preference from within class that extends View.

The Error : "The method getSharedPreferences(String, int) is undefined for the type ViewforRed" , where ViewforRed is my class: Here is the sample code...

View 1 Replies View Related

Android :: Public Class Preference Extends Activity - Null Pointer Exception

Jun 19, 2010

My app crashes with a null pointer exception on the code below. I have an xml preference file under res/xml/defaults.xml
public class Preference extends Activity {
public Preference() {
} public String getPreference(String key)
{ //it still crashes here
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
String result = settings.getString(key, null); return result;
} }

View 4 Replies View Related

Android :: Placing A LinearLayout Inside A TableLayout?

Nov 8, 2010

Im trying to place an image and some text in my view, with the image being twice the height of the text so that the two rows of text can be placed next to the image, like so:
_____
| |text here
|_____|text here

The way i try to do this is to put the two TextViews in a LinearLayout, then place the ImageView and the LinearLayout, containing the text, in a TableLayout with one row and two columns.

When i do this i only se the ImageView. In fact, even when i comment out the adding of the ImageView to the table the text inside the LinearLayout wont show up at all.

CODE:.....................

View 1 Replies View Related

Android :: LinearLayout Not Expanding Inside A ScrollView

Apr 8, 2010

I have a LinearLayout inside a ScrollView that has android:layout_height="fill_parent", but it doesn't expand to the full height of the ScrollView. My layout looks something like:

CODE:........

I can see that the LinearLayout doesn't expand the full height of the ScrollView because in Eclipse in Android Layout Editor, if I select the ScrollView (in the Outline panel) it is highlighted with a red border that fills the screen to the bottom but when I select the LinearLayout its highlight doesn't expand to the bottom of the screen. How can I get it to do so?

The effect I'm trying to achieve is to have some text and a button below it (inside the LinearLayout in level 4 there's just a button). The text can be big enough to need a scrollbar, in which case I want the user to have to scroll down in order to see the button. In case the text is not big enough for a scroll bar, I want the LinearLayout containing the button to stick to the bottom of the screen.

At first I thought I shouldn't post the full XML because it's usually a turn-down to see a huge chunk of code in a question. However, it seems it might be necessary, so here's the full layout.

CODE:........

At the moment I have resorted to android:layout_gravity="bottom" on the problematic LinearLayout, which makes the button stick to the bottom of the screen no matter what. But that also makes the text stick to the bottom of the screen, which is not exactly what I was after.

Update: scratch that, android:layout_gravity="bottom" makes the ScrollView unable to, well, scroll.

View 2 Replies View Related

Android : Create My Custom View Inside A Linearlayout?

Sep 24, 2009

I try to create my custom view inside a linearlayout. For example

<View android:id="@+id/ViewPaint" class="com.example.android.helloactivity.HelloActivity$DrawingView"/>

In the java source I created a DrawingView class which extends View. Unfortunatly it does not get instantiated. I tried to overwrite the ondraw() but without success. Code...

View 4 Replies View Related

Android :: Reason Not To Use App Class To Share Variables Across Activities?

Dec 31, 2009

Is there any reason not to use the Application class to share variables across Activities? For instance a handle to the DB or a single HttpClient.

View 2 Replies View Related

Android :: Run Method From Extends Activity Extends Runnable?

Jul 26, 2010

I'm trying to call a method from inside a Runnable that is running. It waits for a string to be entered and when it is then depending on the string (the strings act as commands) it calls a method and is supposed to run whats inside it. code...

View 2 Replies View Related

Android :: Embed A Class Inside Textview Of Another Xml?

Nov 19, 2010

This is my layout...

This xml is the main.xml with main.java. How can i embed intro.xml with intro.java into the <Textview>?

View 1 Replies View Related

Android :: Loading Layout From XML Inside Of Derived Class

Mar 4, 2010

Right now I have a class that extends LinearLayout and builds the view inside of the constructor using a series of addViews. I wanted to move this into an XML file, so I have the same view defined there. My problem is that I can't figure out how to load the XML file in the constructor of the derived class. I looked up the LayoutInflater stuff, but I wasn't entirely sure how to use it in that context. Do I need to call addView() with the result of the LayoutInflater? Is this even possible? The other issue is that the context object that is passed in doesn't have the LayoutInflater methods. I'm not sure if I need an instance of Activity to do that.

View 3 Replies View Related

Android :: Sending A String Created Inside A Method To Another Class

Sep 12, 2010

I have code which has one activity which passes information to a second activity.
I can use this information to pass to a third activity with additional information from the result of the second activity.

I want to use gestures as a method of going back to a previous activity, but if I go back from the third to the second activity I need the information initially passed from the first to the second activity to still be present.

i.e.

First Acticity

what is Y?

answer y = 5

Second activity

User said Y = 5

what is X?

Third Activity

User said Y = 5
X = 6

Go back to Second activity but maintain the input of

User said Y = 5.

To do this I have used a bundle to pass the information between activities, but I can only access the info in the bundle from within a method within the class started by the intent.

The gesture controls are within another class, so I cannot access the bundle information from within this class as the getIntent command produces a not defined error.

What I need to do is to be able to pass the information from the bundle from the first activity to the gesture class so that I can pass it back when I go back using the gestures.

View 1 Replies View Related

Android :: Check For Internet Connection Inside An Anonymous Class?

Dec 30, 2009

I was trying to make an anonymous class to upload a file to a server.

I wanted to make that easily reusable much like some kind of component.

Everything works fine but as a final touch i wanted to add a function to check if internet connection is available.

Problem is, the call to the connectivity manager needs the Context :

ConnectivityManager connec = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);

Since i'm in an anonymous class and I've read that it's not a good idea to pass the whole context to classes, I wondered about two things :

1 - Is there another way to check internet connection without the Context ? 2 - Why in Android internals make it necessary to have the context just to check if the device is connected to internet ?

View 6 Replies View Related

Android :: Add TextView Programmatically Inside A View-based Class?

Jan 11, 2010

I have been trying to find a solution for this for the last 3 days but i just failed hit a final answer!

I am creating a View-based class where i show a ball bouncing of the sides. I use a Timer to control the animation.

I want to add a TextView programmatically in my view class. I am trying to instantiate an object of TextView with reference to the context as follows code...

View 3 Replies View Related

Android :: Inside Service Class / Executing Method For Toast From Scheduled TimerTask

Apr 30, 2010

I am trying to execute a {public void} method in Service, from scheduled TimerTask which is periodically executing.This TimerTask periodically checks a condition. If it's true, it calls method via {className}.{methodName};However, as Java requires, the method needs to be {pubic static} method, if I want to use {className} with {.dot}.The problem is this method is for notification using Toast(Android pop-up notification) and Status Bar.But for this to work, the method must not have {static} modifier and resides in Service class.So, basically, I want background Service to evaluate condition from scheduled TimerTask, and execute a method in Service class.Can anyone help me what's the right way to use Service, invoking a method when certain condition is satisfied while looping evaluation?

View 1 Replies View Related

Android :: Gradient Styles - Not Working On The Outer-most LinearLayout

Aug 10, 2010

In my Android application I've hidden the default title bar, introduced a TabView and added my own titlebar under that TabView's tabs. At the moment, I'm using the ?android:attr/windowTitleStyle style which makes my new titlebar look gray and gradient. It looks pretty good, but my screens are looking pretty grayscale. I'd like to spice things up a bit by making this titlebar a different color gradient.

What am I looking at here? Creating my own image and using it? The ?android:attr/windowTitleStyle style seems to expand depending on the height of your custom titlebar; so I'm not sure it's actually a single image.

I've attempted to throw a LinearLayout over it with a bit of translucency (ex: making the color #800000FF), but the gradient style I have behind this LinearLayout disappears.

Update:

Per my answer down below, I've figured out that I can create an XML file that defines a gradient and use that. It works fine inside a LinearLayout (titlebar_gradient) I have on my layout. However, it is not working on the outer-most LinearLayout (background_gradient). Could someone tell me why? As I understand it, the ListView should be transparent...

code:...............

View 1 Replies View Related

Android :: Bottom Of One LinearLayout Being Hidden By Other LinearLayout

May 25, 2010

I have a RelativeLayout that has two LinearLayouts in it. One is a bunch of TextViews and EditTexts that make up a form and the other is a ButtonBar that submits the form.

anyways, everything looks great in portrait, but when i switch to landscape mode the bottom TextView/EditText element is being hidden by the buttonbar.

screenshot to show the problem. as you can see some of the "email" textview and all of the email edit text are being hidden by button bar.

http://i45.tinypic.com/2dt7qmt.jpg

and xml:

CODE:............................

View 5 Replies View Related

Android :: Ellipsize Not Working For TextView Inside Custom ListView

Sep 14, 2009

I have a listView with custom objects defined by the xml-layout below. I want the textView with id "info" to be ellipsized on a single line, and I've tried using the attributes. Code...

View 4 Replies View Related

Android :: Tabhost Working In Activity Class

Nov 17, 2010

I must be overlooking something because I am unable to get my TabHost to display in my Activity class.I am getting the dreaded force close when I try to run the app.It will work if I extend TabActivity, but I can't do that [details at the bottom] because once I move the code from my prototype project its going to be in a custom class that inherits from Activity.

View 2 Replies View Related

Android :: Lawyers Working On Class Action On GPS Failure

Sep 21, 2010

Samsung Mobile Phone GPS Defect Complaints - LieffCabraser.com Let They are looking into setting up a class action suit. I gave them my info. and experience online and signed up for their newsletter on this issue. Hope you do the same.

View 49 Replies View Related

Android :: Calling Function From Receiver Class Not Working

Apr 20, 2010

I have a SMSReceiver class that needs to pass the phone number and message to another class. Which works but when I call that class I need the function to read preference to compare if it needs to execute another function.

View 2 Replies View Related

Android :: ScrollView With Buttons Inside / No Response Until Second Click On Any Button Inside

Oct 30, 2010

I've been a couple of days trying to solve this thing but I can'f figure it out.The problem is, simple activity, with simple layout, ScrollView -> LinearLayout -> and a lot of buttons inside the layout (within the scroll content). Everything works just fine but one tricky thing. When I click a button let's say at the top of the scroll content and inmediatelly I scroll down to the bottom of the content and I click other button there, nothing happens until I click a second time and all come to normal again.This can be reproduced anytime and it's code independent (i've tried more than 20 scenarios). I've not much experience in android yet but looks like the scroll listener stops the onclick listener or something like that.

View 1 Replies View Related

Android :: LinearLayout In LinearLayout

Jun 25, 2009

Why is the following code causing an exception? The Code throws a "mBaselineAlignedChildIndex of LinearLayout set to an index that is out of bounds" exception.

CODE:..............

If l2 is dont added to l1 than it works.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved