how to add search result on top of other views - android

I have an EditText in my layout which is used to get the search query from the user. I want to show a LinearLayout bellow it when user enters some characters and fill it with the results (This layout should appear after entering at least N characters). But I don't know how to show this layout?
I thought of putting the whole layout shown in the activity inside a FrameLayout and add the view when required, but there will be two problems:
The view will be added on the top left of the screen.
If I want to move it with adding some padding to it, all the area will correspond to the click event.
To explain what I want more, please take a look at this:

I hope this link will help you, you need to use AutoCompleteTextVIew
http://www.javatpoint.com/android-autocompletetextview-example
https://www.codeofaninja.com/2013/12/android-autocompletetextview-custom-arrayadapter-sqlite.html

These is two approaches for your case.
Use AutoCompleteTextView
Use android-popupwindow.
The former is easier and more acceptable, however if your want to customize the layout of the resulting search, for example arranging them in a gird view, you may what to use the latter option.
Although, AutoCompleteTextView internally uses the latter option.

Related

Creating custom "instruction tips"

I would like to create a view which i could place beside a specific function on the screen as instruction. This "instructiontip" thing will show automatically according to some rules.
The advice I'm seeking is about the way to put such a view anywhere on the screen above all else and not affected by parent type, fx. if added dynamically to a view which root layout is LinearLayout (vertical), I of course don't want it to be places under the last element. I'll place it using coordinates on screen and would expect it to show exactly there.
Here is a design shot for impression:
I keep thinking that there must be a better way of doing that then just adding it and hoping it will show in place.
Activity.AddContentView is a good way of adding such a view above everything else without affecting whatever is beneath.
The only downside is that you can't remove this view after you added it.. but you can hide it if you need to.

How to make RecyclerView with multiple ViewHolders so that one ViewHolder is also controlling another ViewHolders content

I'm trying to implement horizontal scrolling view and managed to actually implement it using this tutorial. Horizontal RecyclerView tutorial
It has it's problems on focusing but at least it works.
Depending use case i have about 2-8 different images to view.
Now my problem comes that my layout is looking like this.
Current layout There is also other fields which isn't included in image.
Now images comes to image field and text would come to text field.
I would like to make those so that when image is moved also text will move at text field but not another way around. When trying to move from the text field it doesn't do anything.
in that tutorial both text field and image field are in same layout but i have separated those and also have that third field which isn't part of the RecyclerView. And adding more to this mess i also have button and when pressing it will change to next image on image field at below layouts.
So what would be good approach to make this to work??
http://smstuebe.de/2016/06/12/mvvmcross-recycler-templates/
You must create an interface to return proper layout for each of your element. You must define all the type of layout in the template selector

Android different media in one view

Ok I do have a question regarding how I would implement this function:
I am creating an application, and in one activity, I want to display several information in the upper half of the screen. Now if I want to display an image, I chose ImageView, if I want to display text, I use TextView, and so on. The user choses what do display in the activity that comes before the display-activity.
Now my question: What kind of View do I chose for this? I was thinking about a WebView, to display images or text. But there is also a chance that I have to display a player for a .wav-file. Does WebView also provide this function? My Problem is that I cannot just say that I chose an ImageView, because it displays no text, and so on. I need a container that can display everything.
Or is there a possibility to overlap like 3 different containers, and activate only the one that I need?
You can have all 3 views in the layout and use Visibility.GONE to hide the ones you don't want. Or you can dynamically add a insert a view at runtime. A simple way to do this second solution would be to put a placeholder view there in your XML layout, and at runtime remove this view and dynamically insert your desired view in it's place.

Replacing views dynamically without changing activity

I would like to know how to go about doing this small problem that I am encountering while making a video player app.
On clicking the first control(the rectangular icon) in the above image the following view must be displayed instead of it which I am quite unsure as to how to do it. Here is what it is replaced by
Also please note, by any chance the activity should not be changed. I have been able to design the views individually but having problem changing them at runtime when user clicks. Could someone go about explaining as to how it can be done or provide some suitable links to achieve my goal. Thanks.
For something as simple as this you can just change the visibility of the views.
view.setVisibility(View.INVISIBLE)
Or the more effective:
view.setVisibility(View.GONE)
Do that on the views you want gone, I suggest a wrapper class. It's either this or changing the contentView as describded below.
this.setContentView(R.layout.newLayoutToUse);
However, I have a feeling there is a better way to do what you want. It's overkill to load a complete new layout if you just want to change the image of some buttons or imageviews.
This might be a stupid solution, 'cause i'm terribly tired right now, but why not use the bringToFront() method on the View that you want to display in the front? Display them both in front of each other, maybe in a RelativeLayout, and then swap between them as you wish.
They are small objects, so don't consume memory. I don't see why this shouldn't work.
OR
Place them above one another, so they overlap and then make the above view visible/invisible depending on which one you need to display.
OR
just remembered I read somewhere that you can scroll through a ScrollView automatically from code. So display both Views in a ScrollView in succession and when pressing the button or whatever, you scroll down to make the next menu visible. When pres back, you scroll up to make the previous thing available. Should work, and might also make a nice animation between changing of the menus.

Nested text view in android,with dynamic content

I want to display a recursive or nested text view at depth of 3 in Android.The text to be displayed is, dynamic coming from web service.
for example:
If I Click on Help(Level 1)
it'll show topics under Help
If I Click on Help_Topic_1(Level 2)
it'll show questions under Help_Topic_1
If I click on this question, say HT_Question_1(Level 3)
it'll show Answer of that question(Level 3)
how to accomplish with this? please guide me.
You should use ExpandableListView. Reference http://developer.android.com/reference/android/widget/ExpandableListView.html
You can call expandGroup and collapseGroup methods for expanding and collapsing on clicks.
the simplest way to do this is to have a nested layout structure. Your root view will contain the button to show level 1 and a child layout and initially be visible. The children's layout visibility will initially be set to "GONE". In the onclick listener for each button you change the visibility of the layout below it to view to "VISIBLE".
This of course is a very simple way of doing it. If you require to have open and close animations you'll need to use a more complex method.

Categories

Resources