How to create an custom ListView? I have Adapter, but I don't understand how to create an View like ListView of the Facebook, or App for SMS native from device... I'm needing background for TextView, this background, will have an arrow pointing left or right, I tried to create a View using canvas, but it is very difficult...
Every line in the listView of a layout which can be as complex as you want.Just you need an extra xml file for managing you custom layout (it should be contains widgets,fields,images etc as your design ) and the adapter would inflate this layout file for each row in its getView () method and assign the data to the individual views in the row .
Related
I have this activity, with a list of tokens/options in it. As of right now, i have a button that, using intents, opens a new activity based on the item selected (basically: a text to modify the settings and add extra info).
Now, i would like to make the first activity to show, in the below half of the screen,a preview of the new activity, but with fewer/diferent options and less information.
I know how to do that using fragments, but i don't know how to approach the creation of the new activity.
Is there a way to merge them both, to pass the first fragment to the second activity, or do i need to completely code (and thus, modify) "twice"?
Is there a better aproach that lets me do that easily?
If considered you are inflating options in recycler view in the activity, add a frame layout in the same as a container for a fragment to preview the new activity. Set the visibility to gone for the frame layout and when an option is selected set the fragment and display it. For a nice animation use android:animateLayoutChanges="true"
in the options activity xml at the root view. Hope I helped happy coding :)
So I'm trying to make an event organization app. The user needs to be able to manage multiple events at the same time. So, if he clicks on 'add event', I must be able to dynamically create a new layout folder for that respective event. How do I go about doing so?
It is not possible to "dynamically create a new layout folder for that respective event" but according to your requirement u can generate views dynamically according to your requirement or inflate a layout
(inflate layout)
1>How to inflate one view with a layout
generate view dynamically from code
2>Dynamically add textViews to a linearLayout
Hope this may help you
I'm developing an Xamarin Android Mvx5-beta application. When running on a small-screen device, I want to show a drawer navigation using the Toolbar and the hamburger-icon. On larger devices, e.g. tablets, I want a different layout conaining three columns. No drawer navigation but a static panel with navigation options and two other panels for content.
I started with the examples XPlatformMenus and Fragments to get a drawer navigation layout combined with the use of activities (with fragments) in different layouts qualifiers, like:
Question:
Using this approach, Android automaticly looks for an activity with the same name (e.g. main_activity.axml) in the appropriate layout-qualifier folders. But on the larger screens I don't need a drawer layout and I do need an extra column. The Mvx-viewmodel does not yet know what layout to render, so it just calls:
ShowViewModel<HomeViewModel>();
ShowViewModel<MenuViewModel>();
These ViewModels, for example MenuViewModel, are registered for fragments that require a navigation_frame, as shown in here:
[MvxFragment(typeof(MainViewModel), Resource.Id.navigation_frame)]
[Register("mydemoapp.droid.views.fragments.MenuFragment")]
public class MenuFragment : MvxFragment<MenuViewModel>, NavigationView.IOnNavigationItemSelectedListener
{
<..>
}
So, rendering this same Activity in layout-sw600dp requires a navigation_frame. Which I don't want on these larger displays.
What would be the preferred design choise in this situation? I can think of two:
Show/hide elements in the Activity programmatically by querying the screen info
Don't make use of layout qualifiers, but design complete seperate Activities for larger screens and based on screen size let MVX Show ViewModel-A or ViewModel-B.
Any advice would be appreciated, many thanks in advance.
I think it depends how different your layout need to be between large screen and small screen form factors.
Few UI differences
In addition to using different layouts, you can define a bool property in your XML values resources that is different between standard and sw-600dp
values
<bool name="is_large_screen">false</bool>
values-sw600dp
<bool name="is_large_screen">true</bool>
You can then read this value in your Android views and prevent methods like ShowViewModel<MenuViewModel>(); firing when on large screens by altering the method calls from the view.
Many differences/Structural differences
If they share the same business logic but have very different UI requirements and you want to keep large screen code separate. Then I would suggest sharing the ViewModels but creating two separate Activites and layouts to handle the UI presentation. Using this method requires a bit more setup as you have to override some default MvvmCross behaviors as by default you can not register multiple Activities/Fragments to the same ViewModel. Overriding the MvxViewModelViewTypeFinder view lookup FindTypeOrNull you can intercept the lookup and filter types base on naming conventions. For example all large screen views end with "Tablet". Using the is_large_screen bool you can flag which views to register.
I have a game (Unity3d) that is running on Android where its View is contained in a FrameLayout. The game view covers the entire screen.
I am adding (in code) another view next to this view another button view (the 2 views overlap - see images below).
The button does not receive any input.
According to the documentation for FrameLayout, it is advisable to use a single element under it, but multiple views are also possible.
Why does my button not receive any input?
Attaching the view state as captured in Eclipse.
I'm new to android development and needs help here.I want to create a layout where buttons are added dynamically.In this the no of buttons to be added are decided on the fly.(at run time) i.e depending upon the number return by server i want to add buttons.below is the layout i want to create.Please suggest me suitable solution.I was trying creating this layout with table layout.Thank You
http://i.stack.imgur.com/tbrEq.jpg
Read in your array of buttons and initialize your empty layout (i.e. setContentView). Then, create your buttons using the ImageButton constructor and call .addView(btn) from the layout where you want to insert the button. Don't forget to set any layout parameters you need.