android-ui

Creating custom back button in android

北城以北 提交于 2019-12-06 03:26:18
问题 I have an application that has a menu and depending on what button you press in the menu a new activity is opened. I want to have a back button on every screen that will bring you to the previous screen so I'm wondering how do I go about this? Here is some code I have used that works: backButton = (ImageButton) findViewById(R.id.back_button); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); However its not good programming

expandable-spinner : How to implement expandable spinner entry in Android

只谈情不闲聊 提交于 2019-12-06 01:35:37
I am building an Android application, in which i've a spinner item. The spinner entry is a category, and there are sub category in each category. I want to implement a UI, such that, when i click a spinner entry, i must get another spinner, showing the sub-categories for that category. (Something like how Windows Program menu works). Here's and image of what it must look like - Consider the drop down as a spinner. I figured out these many ways - Implementing Spinner of Spinners. Populating new spinner on every item-selected. I am confused, as which method is efficient and easy to maintain.

Instantiating a View on non-UI thread

China☆狼群 提交于 2019-12-06 00:06:16
I know that the UI elements (View hierarchy) may only be manipulated from the UI thread. For a background operation, the AsyncTask can be used, which offers event handlers to reach the UI thread. To be brief, is it allowed to instantiate a View (tied to getApplicationContext() ) in a non-UI thread? This custom View descendant -- once instantiated -- is added to the view hierarchy from the UI thread . So only the constructor call is done inside an Asynctask.doInBackground() ; it's attaching ( addView(...) ) to the Activity's root layout hierarchy is still done in the UI thread. In details:

Integrating uiautomator test case with application code in Android

北城以北 提交于 2019-12-05 21:22:20
I am using Eclipse IDE. Here is my code for uiautomator testcase: public class caltest extends UiAutomatorTestCase { public void testDemo() throws UiObjectNotFoundException, IOException { //mytesstcode } } To run this test i have to issue following commands from command line: /tools/android create uitest-project -n -t 1 -p Go to the project directory where your build.xml file is located and build your test JAR. ---> ant build Deploy your generated test JAR file to the test device by using the adb push command: ---> adb push /data/local/tmp/ ---> adb shell uiautomator runtest jarname.jar -c

How to use two different font sizes for button text in Android?

本秂侑毒 提交于 2019-12-05 19:33:52
How could I implement a button background for ImageButton or Button which contains 2 textview each using different font sizes ? I cant use static images as background and I need to achieve this either using xml or programmatically. This is a numeric keypad and it carries a numeric value and a set of alphabets each of which uses different font sizes and needs to be set as button text. Here are some of the suggestions that pop-up on my brain but seems to have limitations since I want to reuse the UI component and avoid code repetition. Create a layout xml containing 2 textfields and set that as

How do I get action buttons with custom layouts to be styled like standard action buttons in Android 3.0+

纵然是瞬间 提交于 2019-12-05 14:49:34
I'm having a bit of trouble with custom action buttons in the honeycomb+ action bar. I'm adding a menu item that uses a custom layout (using the android:actionLayout attribute). The reason for the custom layout is that I want a button that has two lines of text that can be updated dynamically. However, I still want this action button to operate like the other standard buttons. By this I mean that the background fades in when the button is selected, and fades out again if it is unselected, all in the style of the platform (the colour seems to differ between different platforms/devices - I've

Reverse the direction of a LinearLayout

倖福魔咒の 提交于 2019-12-05 13:28:47
问题 How can I reverse the direction of a linear layout? for example, if my layout is [view1, view2, view3] I want to create [view3, view2, view1]. My goal is to inflate a left and a right handed instances from one XML layout. 回答1: Generally I would say you cannot do this using the standard SDK. You could however create a method which gets all of the subviews out of the LinearLayout, removes them from the LinearLayout, and then adds them back in reverse order. LinearLayout ll = // inflate

Remove series indicator/plot legend AndroidPlot

点点圈 提交于 2019-12-05 11:40:46
I realise AndroidPlot has a forum but it isn't the most active so i'll chance my arm here... I'm trying to remove the series indicator or plot legend from my XY plot using the AndroidPlot library. I don't want to remove the series from the plot itself, just the legend. I've seen it done on AndroidPlot examples but with the limited documentation it's difficult to find methods to do the stuff like remove the legen OK I have the following code to do this. This is not tested on the very latest version but hopefully is still good. if (!mKeyOn) mDynamicPlot.getLayoutManager() .remove(mDynamicPlot

How to achieve Android UI like this image layout? About android:clipChildren

有些话、适合烂在心里 提交于 2019-12-05 11:22:24
What I want to achieve is like this layout: I have tried to use this code, to achieve like that image, but unfortunately, I failed. This is the snippet of my code: <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:clipChildren="false" > <RelativeLayout android:id="@+id/text_area_third" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/round_corner_background" android:focusable="false" android:paddingBottom="5dp" android:paddingLeft="5dp" android:paddingRight="5dp

android:pitfalls of deleting ldpi/mdpi folders

别说谁变了你拦得住时间么 提交于 2019-12-05 10:21:53
I was wondering what are the pitfalls of deleting the ldpi/mdpi/hdpi folders on my android project? Can i just copy all the images in the drawable folder instead? I did see the following links about UI development for android http://developer.android.com/guide/practices/ui_guidelines/icon_design.html http://developer.android.com/guide/practices/screens_support.html thanks PS: I 'm referring to all the images that are being used, background,icons,menus etc... If you want to, go for it. Although not the best practice, if your application is quite conservative in terms of graphics then this may