android-ui

Get the position of the current image displayed in Gallery

▼魔方 西西 提交于 2019-12-05 02:19:06
in my application , i have a gallery of pictures, but i want to detect the position of the current image displayed , For example : when i launch my acvitivity, the position is 0, but when i scroll in my gallery,i want to get The position of the Current image displayed , i have tried OnFocusChanged , OnItemClicked , but that works only if i click on an item of my gallery Any ideas ! :( gal.setOnItemSelectedListener(new OnItemSelectedListener(){ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { //Do something with position } }; You get this callback

Memory leak through IClipboardDataPasteEventImpl

拈花ヽ惹草 提交于 2019-12-04 19:51:45
问题 I noticed an odd memory increase in one of my Activities. Hence I ran a little test: I opened the dialog multiple times (open - close - open - close ....) and the memory kept increasing. So I used the DDMS to dump an HPROF file and opened it in MAT (Memory analyzer). The leak suspect report indicated, that the main reason for the growing memory consumption was this: So I did a histogramm, to check that dialog I ran my tests on and what's keeping it alive. Turns out, it's kept alive by it's

How to customize ActionBar in Android (ActionbarSherlock)?

主宰稳场 提交于 2019-12-04 19:46:16
I have used ActionBarSherlock in my application for providing ActionBars to pre honeycomb devices. I want to use Light.DarkActionBar Theme in, How can I customize following for parts of the ActionBar (see image) Background color of ActionBar Background Image for ActionBar tab bar The bottom line which represents the selected tab The divider between tabs... I have tried using following settings, Though I have achieved some success but the result however doesn't look as expected, <item name="android:background">@drawable/bg_title_bar</item> <item name="background">@drawable/bg_title_bar</item>

Android Night Mode without CarModeEnabled

这一生的挚爱 提交于 2019-12-04 19:25:42
问题 So I made separate xmls for night mode and kept them in layout-night . Then I switch to night mode: UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE); if (nightMode) { uiManager.enableCarMode(0); uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES); } else { uiManager.disableCarMode(0); uiManager.setNightMode(UiModeManager.MODE_NIGHT_NO); } Is it possible to set night mode without enabling car mode? or for that matter possible to use layout-night, values

Updating Activity UI from Intent Service?

百般思念 提交于 2019-12-04 19:25:39
I need to download some files (10-20 or depends on user) from service in my app. The problem is I am using IntentSevice and finding it hard to update activity UI. I know following ways to update UI Use handler and send messages from service to activity using Messenger like this . Send broadcast intents. Using first method would cause problem once activity is closed & re-opened and also I am not sure about its performance. Using second would definitely cause perfomance issues since I need to update UI quite frequently (once or twice every two seconds). Is there anyother possible way of

Android Fragment Tabs Example

心不动则不痛 提交于 2019-12-04 18:20:38
问题 I am currently working on 2.3 version of android and I want to switch my app to 4.0 version but the TabActivity is deprecated. So I was looking for working example of FragmentTabs but I am not able to find one. Can anyone help? 回答1: I've found the FragmentTabs example from the API Demos project to be very useful. Just create a new Android sample project from Eclipse and choose the API demos (try API 13). Also for the support (compatibility) library, there's a FragmentTabs demo in the

android UI external libraries?

筅森魡賤 提交于 2019-12-04 15:44:52
问题 I'm starting with android, and the app I'm developing is gonna need custom widgets look (glossy buttons, animated backgrounds etc.), I've googled for any external libraries to achieve this and did not find anything. let me guess, the only way to this is by painly extending base view classes and overriding onDraw etc. ? 回答1: You need to explore View Styles. You can customize almost any view element. You might not need any external library that extends and designs custom buttons. More ref: http

Toast message not shown

大城市里の小女人 提交于 2019-12-04 15:02:40
I am trying to show a toast message in my application using the following code. AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Do you want to continue?"); alert.setPositiveButton("Continue", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { try{ //This code generates an Activity Not Found exception } catch(ActivityNotFoundException e) { System.out.println("Activity Not Found Exception Raised"); Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_LONG).show(); // For the context I tried using

Dynamically position right corner arrow of the ActionBar Spinner based on length of displayed title

﹥>﹥吖頭↗ 提交于 2019-12-04 14:15:58
问题 In the Google+ App, the position of the right corner arrow of the ActionBar Spinner adapts to the length of the current string showing. For example, the Spinner's length seems shorter when Family is picked versus when Acquaintances is picked. What do I have to do to get the right corner arrow to position dynamically based on the title's length? My guess is that there's an attribute I can set in styles.xml that will do that for me. Here's my styles.xml: <style name="MyStyle" parent="android

Creating custom view

∥☆過路亽.° 提交于 2019-12-04 14:08:37
问题 I want to create a custom view TestView class for which I can create object via new TestView() . A new view class however needs a AttributeSet object. From where do I get that AttributeSet and what does it have to include? 回答1: It's not mandatory, and most times you don't even have to worry about it as long as you provide constructors from View that pass them along to super() . public CustomView(Context context) // No Attributes in this one. { super(context); // Your code here } public