Skip to main content

Posts

Showing posts with the label android-layout

AutoStart Application not working properly

I am having a Simple AutoStart Application with TimerTask implementation, that works fine in almost many devices. The problem is that it is not working in Samsung Galaxy Y(2.3.6) and DELL XCD35(2.2) . When the device boots TimerTask works for some seconds and then shuts down. I check in the Application->Manage Application , I saw that the Applcation was already in Force Stop State. That means some how my Application gets stopped after some seconds. So, what is the reason for this weird behaviour in these two devices, if anyone has the solution do share it.

converting pixels to dp in android

I have created my application with the height and width given in pixel for a pantech device whose resolution is 480x800. I need to convert the the height and width for an G1 device. I thought converting it into dp will solve the prob and provide same solution for both the device. is there any easy way to convert the pixels to dp?? or any suggestions?? Source: Tips4all

Android: How to track down the origin of a InflateException?

While starting my application I get the following warning in Logcat: 04-09 10:28:17.830: WARN/WindowManager(52): Exception when adding starting window 04-09 10:28:17.830: WARN/WindowManager(52): android.view.InflateException: Binary XML file line #24: Error inflating class <unknown> 04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater

Image is not fit into QuickContactBadge

I have create a listview of Contact numbers , the list item contains the QuickContactBadge and TextView now whenever i tried to load image into QuickContactBadge it does not get fit into the QuickContactBadge Frame and at the same time QuickBadgeContact itself will also get shrink. Rite now i have this What i am trying to achieve is so not only image but even i am trying to make QuickContactBadge of a normal size here is my code that i am using Uri contactUri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactId)); InputStream input = ContactsContract.Contacts.openContactPhotoInputStream ( getContentResolver(), contactUri ); cache.photoView.setImageBitmap(BitmapFactory.decodeStream(input)); My Layout for list item <QuickContactBadge android:id="@+id/badge" andro

Android button with image background and text and stateful functionality

I want to create "button" in XML layout (if possible) which has background image based on state (this image is NOT 9-patched) and with text. Which component to use? My button_states.xml looks like: <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/my_pressed" /> <item android:drawable="@drawable/my_normal" /> </selector> my_pressed and my_normal are NON 9-patched images. Now if I use regular button <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_states" android:text="@string/my_text" /> button it is rendered without background image. How to do "button" with text a

Linearlayout gravity issue?

Ä° have problem about linear layout. i think something is weard.All of them same layout but back button moving related icon buton.I want to fit back button on the left side and btn_header_what_search_user button want to right site.But they are moving related icon(center icon).Why? and how can i back button on the left side. my code:` <LinearLayout android:layout_height="44dip" android:layout_width="320dip" android:background="@drawable/header_320_44dip"> <ImageView android:layout_width="121dip" android:layout_height="32dip" android:layout_gravity="center" android:layout_marginLeft="90dip" android:background="@drawable/icon"> </ImageView> <ImageView android:layout_width="52dip" android:layout_height="32dip" android:layout_gravity

Android - calculating and storing the answer of an arithmetic expression

What would be best way to get the answer to this question which is using random numbers and random operators. editTextEquation.setText(random1 +(String.valueOf(ops[i1]) + random2 + (String.valueOf(ops[i2])+ random3 + (String.valueOf(ops[i3])+ random4)))); I'm displaying this question and then will check the answer against user input. I'm guessing I'd need to store the answer first. Any help/advice will be very much appreciated. Here is how I am generating the expression: int random1 = (int)(Math.random()*100); int random2 = (int)(Math.random()*100); int random3 = (int)(Math.random()*200); int random4 = (int)(Math.random()*20); int min = 0; int max = 3; Random r = new Random(); int i1 = r.nextInt(max - min); int i2 = r.nextInt(max - min); int i3 = r.nextInt(max - min); char[] ops = { '+', '-', '/', '*' }; int answer;

Change Activity layout

In my app i want to change the Activity contentview if a button was clicked for example. In the begining i call the first layou: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.catalog); } and when a button was pressed i call this one: public void showItemActivity(int position){ setContentView(R.layout.item_view); } and in this method my app crash. i need to say that if i try this method: setContentView(R.layout.item_view); in the begin of another Activity it work perfectly, but it reali important for me that it will be in the same Activity . Edit the logchat error msg: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

Android navaigation bar with ListView

i just did ListView like this: All source: ListView Now i want to add navigation bar like iPhone on top of this window: I was searching for some source how to do but just kind find. Maybe someone have bookmarked good tutorial how to do this ?

getRotation() of layout in Android 2.1

I have an android application I have build for Platform 4.0.3 and I have used getRotation() and setRotation() Methods to rotate my layout but I have to make the same application for Platform 2.1 and when I try to do that I can't find getRotation() or setRotation() Methods so if anyone know the corresponding methods or way to do so I will be Thankful Thanks in Advance

Reuseable activties?

Hi i have a couple of question regaurding android and activites, i have tried looking online but can't seem to find what i am looking for, anyway; Say i have a menu activity with an option to create new "drawactivity", when user selects this an activity is presented with a toolbar on the top the lower enables the user to draw, then the user will save this activity and quit, when the user returns to the menu, the last activity the user was on is avaiable to load and the create new option is also avaible. So here are my questions; How is it possible to load an activty with a predefined layout and fuctions/code ready? and reuse it? Save this activity Load this activity If you have any resources or anything to point me in the right direction it would be greatly appreciated. Many thanks.

Designing animation for android application

What is the best way to design and embed an animation into an android app. (I'm not talking about transitions and activities in/out animations.) I can think of 2 ways of doing it: designing the animation with flash or something similar, export png-sequence with transparent bgs and creating an animation from the images in an xml file (How do I write this kind of xml?) creating a grid of images with all the frames of the animation that I've created and save it into one image. than using something like background-position in css in order to move the visible area of the image on each frame enter (By Java code, or by xml) which of this is better/most common? and how do I implement the solution (if there is a better solution - that would be great). and what programs do you usually use for this kind of task (the goal is to achieve something that works like the frog in cut the rope or the birds in angry birds for example) thanks!

Android Exception trying to open a new Activity - Surface::lock failed, already locked

When I try to open a new activity on a button press i get an Exception : 01-19 14:55:08.327: E/Surface(15454): Surface::lock failed, already locked 01-19 14:55:08.327: E/SurfaceHolder(15454): Exception locking surface 01-19 14:55:08.327: E/SurfaceHolder(15454): java.lang.IllegalArgumentException I have a game that draws on a surfaceview canvas with a thread, that runs with the main process, I'm trying to open a new dialog box for input and nothing worked so I'm simply trying to open a new Activity that will Exception, I'm using the lock and unlock and well synchronized, I tried stopping the thread and even placing a couple of views. Any help is good Thanks.

showing menu without pressing menu button

I want to create a menu which must be visible in my all the activities.There are around 5,6 activities in my application. So i created a menu but that menu appears after pressing menu button.I want to appear menu without pressing menu button. Please tell me the code that shows menu on start of any activity. I am giving you image the way menu look like. ![enter image description here][1]

How do I change the background color of default keyboard used in an app?

So the app I am making requires a darker keyboard to be used (or else the contrast between content and keyboard is far too high), so I need to change what keyboard appears when I interact with an EditText. I've taken a look at the Android Soft Keyboard , but I'm having a hard time following it. If someone is able to help me with that, it'd be wonderful, though I am hoping there is an easier way out there already. Thanks.

split action bar doesn&#39;t appear?

i want to make action bar top and down in android 4.03 make code but when i run it it doesn't appear , i don't know what is wrong , i search for reson before asking here but i didn't find anything here is menu/style.xml code: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/first" android:icon="@drawable/cat" /> <item android:id="@+id/first" android:icon="@drawable/phone" /> <item android:id="@+id/first" android:icon="@drawable/music" /> <item android:id="@+id/first" android:icon="@drawable/dialog" /> <item android:id="@+id/first" android:icon="@drawable/file" /> <item android:id="@+id/first" android:icon="@drawable/contact" /> <item android:id="@+id/first" android:icon="@drawabl

Android Creating button dynamically and fill layout

I'm creating a button dynamically. The number of button is depend on the size of arraylist. the problem is, after creating the button I will add to the layout using addview method. The problem is I'm using linear layout, as by default orientation for linear layout is horizontal, so the button will fill the layout horizontally. Because of that some of the button is not visible. What I'm trying to achieve is something look like this My code is like below: Button[] tv = new Button[arraylist.size()]; for(int i=0;i<arraylist.size();i++){ tv[i] = new Button(getApplicationContext()); tv[i].setText(arraylist.get(i).toString()); tv[i].setTextColor(Color.parseColor("#000000")); tv[i].setTextSize(20); tv[i].setPadding(15, 5, 15, 5); linearlayout.addView(tv[i]); } If I set the orientation of linear layout to vertical the button will fill vertically. So if there any solution to create the button dynamical