android-layout

How to inflate Android View in LinearLayout class?

天涯浪子 提交于 2020-01-29 12:04:12
问题 I've got a little piece of xml, which I'll be using in a lot of places in my app. For this reason I want to store it in a separate file. So I created mywidget.xml in which I have my xml. I then try to inflate this in mywidget.java, after which I want to include it in a different xml file like so: <com.mycom.android.ui.widget.AmountWidget android:layout_width="fill_parent" android:layout_height="wrap_content"></com.mycom.android.ui.widget.AmountWidget> In my java file, I try to inflate the

Setting the Android System Volume

∥☆過路亽.° 提交于 2020-01-29 09:35:28
问题 I am writing an application which handles the following: Silent - Makes the phone volume silent Low - Makes the phone volume 1 point above the silent Medium - Makes the phone volume medium High - Makes the phone volume maximum Phone volume includes Ringer, video, audio , games volume etc. I know how to achieve Silent mode through AudioManager . But for 2-4 , I could not find any helpful code snippets. What do I need to do? 回答1: Add this in onCreate() method of your code and then play around

Setting the Android System Volume

大城市里の小女人 提交于 2020-01-29 09:33:25
问题 I am writing an application which handles the following: Silent - Makes the phone volume silent Low - Makes the phone volume 1 point above the silent Medium - Makes the phone volume medium High - Makes the phone volume maximum Phone volume includes Ringer, video, audio , games volume etc. I know how to achieve Silent mode through AudioManager . But for 2-4 , I could not find any helpful code snippets. What do I need to do? 回答1: Add this in onCreate() method of your code and then play around

Android How to create a View Programmatically

笑着哭i 提交于 2020-01-29 07:53:44
问题 I need to create a view programmatically. The controls(buttons, labels, etc.) and their positions are known only at runtime. Here I found "Defining a Layout Programmatically": http://mobile.tutsplus.com/tutorials/android/android-layout/ but I need to be able to draw components at exact locations so LinearLayout, TableLayout etc. doesn't work for me. How can I do this? 回答1: Create a custom ViewGroup; this allows you to manage placements of each of the children you have (buttons, labels, etc)

Android How to create a View Programmatically

醉酒当歌 提交于 2020-01-29 07:53:05
问题 I need to create a view programmatically. The controls(buttons, labels, etc.) and their positions are known only at runtime. Here I found "Defining a Layout Programmatically": http://mobile.tutsplus.com/tutorials/android/android-layout/ but I need to be able to draw components at exact locations so LinearLayout, TableLayout etc. doesn't work for me. How can I do this? 回答1: Create a custom ViewGroup; this allows you to manage placements of each of the children you have (buttons, labels, etc)

ScrollView with a ListView doesn't scroll - android

巧了我就是萌 提交于 2020-01-29 04:11:26
问题 My problem with the following layout is that the layout doesn't scroll. My requirement is that I have to display 2 lists which at times can be big. So i put both the ListViews inside a ScrollView so that i can scroll to the bottom and have a look at both the ListViews. I don't want the ListView to scroll . I only want my ScrollView to behave as it should. Any suggestions?? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android

Add custom view as a view of XML layout

好久不见. 提交于 2020-01-28 11:21:26
问题 The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout _run_workout.xml_ with some labels that are updated by CountDownTimer . Works fine... Now, apart from labels that are updated every sec by onTick() callback method of CountDownTimer object I want to add a custom surface view to my _run_workout.xml layout_ that would draw some arcs updated by the same onTick() method every second... my run_workout.xml: <training.timer.CounterClockView android:id="@

Add custom view as a view of XML layout

北城以北 提交于 2020-01-28 11:21:05
问题 The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout _run_workout.xml_ with some labels that are updated by CountDownTimer . Works fine... Now, apart from labels that are updated every sec by onTick() callback method of CountDownTimer object I want to add a custom surface view to my _run_workout.xml layout_ that would draw some arcs updated by the same onTick() method every second... my run_workout.xml: <training.timer.CounterClockView android:id="@

Cannot find R.layout.activity_main

陌路散爱 提交于 2020-01-27 03:36:46
问题 I was trying to work out with multiple layout using some online tutorials. The thing is my program was building and compiling correctly as long as there was only one XML file. When I added multiple XML files, I am getting errors saying 'activity_main cannot be resolved or is not a field' for the line setContentView(R.layout.activity_main); In fact, every item which I used previously in R.* is now reporting error. I don't know what went wrong. Can anyone suggest what needs to be done? Edit 1:

Passing Data between Arbitrary amounts of Fragments via one Activity

随声附和 提交于 2020-01-26 03:36:19
问题 I have an application design question regarding passing data between fragments. I have an application using the navigation drawer layout, with various "sub applications" that perform standalone functions (for example, a calculators app, with unrelated "sub apps" for income tax calculations, metric/imperial conversions, etc). For a given calculator, I'd have a data entry/selection fragment and a data presentation fragment that displays the calculation in some meaningful type of way. Thus, my