Android - Drawer navigation adapter - android-listview

I am implementing a navigation Drawer as per: http://developer.android.com/training/implementing-navigation/nav-drawer.html
The tutorial only shows a single TextView with ID android:id="#android:id/text1" and this is populated for the ListView using:
mDrawerList.setAdapter(new ArrayAdapter<String>(
this,
R.layout.drawer_list_item,
mDrawerItems));
Now, I want to include an ImageView inside each ListView item. This will represent the Icon for each item.
Question: Inside my xml for the list items (where the TextView text1 is located), I have included an ImageView.
What do I need to name the ID for the ImageView?
And then, do I simply add the drawable-array reference to the setAdapter like this?
mDrawerList.setAdapter(new ArrayAdapter<String>(
this,
R.layout.drawer_list_item,
mDrawerItems,
mDrawerIcons));
Thank you

I found out that creating an ArrayAdapter in the format above does not allow you to input more than one set of data to the Adapter. For instance, I can only use my list of Drawer Navigation names contained in the Array<String>: mDrawerItems. To pass Icons and other data to the adapter, I have two option:
Simple Adapter used with a Map, or
Custom Adapter.
Examples of both can be found here: http://www.vogella.com/articles/AndroidListView/article.html, and here:
http://www.shenhengbin.wordpress.com/2012/03/17/listview-simpleadapter/

Related

Is there a way to add input field in nav element using React FluentUI (#fluentui/react)?

The examples on website show many examples of navbars with links.
Image of navbar demo as shown on website.
I want to implement a search bar inside the nav element like this. Is there a way to do it?
I would try with OnRenderLink or linkAs methods.
onRenderLink:
Used to customize how content inside the link tag is rendered
linkAs: Render a custom link in place of
the normal one. This replaces the entire button rather than simply
button content
Source: INavProps interface https://developer.microsoft.com/en-us/fluentui#/controls/web/nav

UI5 Generic Tile with filter functionality

I have Generic Tiles in my UI5 App. My requirement is to implement the functionality of Icon Tab Bar - Filter (https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.IconTabBar/preview) for these tiles. I have separate tile for each status and on clicking it should display the list in the table depending on the clicked status eg: 'completed tickets'.
The table and the tiles are in different views. If this is possible please provide suggestions as to how this can be accomplished.
Thanks,
Srinivasan
You could follow the example of the IconTabBar almost literally, and just swap the icons for tiles.
When you press an icon in the IconTabBar in the example, the logic connected to that icon will add a filter to the binding of the table. You should do the same: the logic connected to your tiles, should also change the filter of the table binding. Every tile could result in a different filter to the binding. With that, you would see the table filtered based on the tiles you clicked.
With your table being in a different view than the tiles, you may want to use the router to communicate between the two views. You could e.g. have tile one to navigate to /YourApp/#/Stuff/FilterBySomething and tile two to navigate to /YourApp/#/Stuff/FilterBySomethingElse. In the view containing your table, you should then pick up the filter info and add the filter to the table binding accordingly. More info on how this works can be found in Step 31 of the SAPUI5 walkthough.

Steps for creating a custom view

How can I create a custom view with a custom style? I have many TextView's in my layout and its kind of difficult to manage all of them. I want to group them in a custom view with custom look (a box with rounded corners) and in my code just give the values to the custom view code to handle it itself.
What I am looking after is something like:
Can someone plesae tell me the steps to create such custom view with rounded box and few TextView's inside it?
Two approaches:
You can create a layout for your view. You need to take different layout widgets like textviews etc. and assign them values.
You can use canvas to draw such view.
The proper way is to inherit from View. Either programatically or in designer You assign any layout to this view. To the layout You assign Your elements ( TextViews, whatever ).
Create methods in the derived View class which fill the inner elements, something like getters/setters, like properties in c#. Those are public.
Then place Your custom compound control onto Your main view.
I for myself created a column orientated tablecontrol with custom scrollbar this way ( but pure via code ) and it works very well. Ah, and additionally You can draw shapes on Your derived view, which allow You relatively simple to apply round corners, and even color transitions.
I'm assuming you're using eclipse to create your android project.
Go to your src file and create a new layout (relative layout works best here). There is a visual representation of the layout you're creating so you should be able to play around with it. Drag and drop the textviews where you want them and give them unique names. Then in your java code, call the textviews like:
TextView text = (TextView) findViewById(R.id.textview_name_here);
text.setText("Your Text Here");
There are plenty of examples online.

Add/remove usercontrol in panorama item using MVVM - Windows Phone

I have a panorama app that has two panorama items so far, "recent" and "popular." These get populated with data using binding from a viewmodel. I would like to add a third ("search") panorama item that initially shows just a text box and a button.
When the user inputs text and clicks on the button, I want the text box and button to be replaced with the ListBox control that shows the search results.
I cannot find any examples on how to do this using the MVVM pattern. I am not using a MVVM framework and would like not to since I am just learning all this.
If you can explain or better, point me to examples that will allow me to do this, I would very much appreciate the help. If I left out any required info in my request, please let me know.
Sincerely,
Kamal
Typically for something like this you would have a property in your ViewModel that would tell the view what to show. You have lots of different options for how you could do this.
One option would be to have a Results property that your list box is bound to. Put the textbox and button in a Grid and bind the Visibility property of the grid to a property that is Visible is there are no results and not visible if there are.
Lots of different ways to do this.
Examples here and here.
You could probably bind a list of a custom class to the panorama ite .
The custom class contains a title and/or description and a page class.
You can maintain your views in your main viewmodel.
Another solution would be adding the items in xaml and using the same viewmodel for the whole panorama item control. With a property you can control the visibility of each item.
Like Bryant said: there are so many solutions. It depends on your application and requirements... :)

How to create a custom listview like iPhone in Android

I was designing a custom listview in Android following the online tutorial Android Series: Custom ListView items and adapters and I created a custom list view like this:
This is simple and fine. Now I was surfing the web and found this fantastic listview for iPhone:
How can I create something like this? How has he given a box like interface for each row separating them from background and each other?
You could try removing the list dividers (android:divider="#null" or android:dividerHeight="0px") and using a custom drawable as the background for each row (either a 9patch or ShapeDrawable, possibly arranged in a StateList so they can have pressed/selected states). Then just also put a margin on the row layout, and your spacing should be taken care of (alternatively, you could use a transparent image as the list's divider with an appropriate height). But be careful about simply aping an iOS style because it looks nice; think about the typical Android user and what they take as interface cues. If you made your Android list look exactly like that screenshot below, I think many Android users wouldn't even realize they could click on those rows, or that they're part of a scrollable list.
The listview and each item in the listview can have separate backgrounds. So all you need to do is make some PNG files that look like the background of the items and the list itself.
You can set the backgrounds in XML using the android:src.
Or at runtime using:
setImageDrawable(getResources().getDrawable(R.drawable."picture name"))