Feed Buzzard

Cooking content that keeps your audience buzzing

  • General
    • General News
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • Latest
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
  • General
    • General News
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • Latest
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
Feed Buzzard
No Result
View All Result
Home World Tech

Spinner does not wrap text — is this an Android bug? –

Gordon James by Gordon James
December 25, 2020
in World Tech
0
0
SHARES
71
VIEWS
Share on FacebookShare on Twitter

Development issue/problem:

If the text of a filiform element is too long to fit on a single line, the text is shortened instead of wrapped. This is only the case with an API level >= 11. Here are screenshots of Android 4.2.2 (left) showing the bad behavior, and Android 2.3.3 (right) where it seems as expected.

android:singleLine=false is just being ignored here. Like all other attempts such as android:lines, android:minLines, etc. it is not possible to use the same software. For some reason, TextView seems to be much wider than the width of the window.

I saw that other people had the same problem, but no one could find a solution. So it’s a system malfunction? I don’t think this discrepancy between the OS versions can be deliberate.

Some questions were relatively easy to answer.

UPDATE: I also uploaded this project to GitHub as an example: Download

/res/values/array.xml :

Lorem ipsum dolor sit amet, consetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.
In vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est.

/res/lay-out/spinner_item.xml :

Install the adapter :

spinner.setAdapter(ArrayAdapter.createFromResource(this,
R.array.items,
R.layout.spinner_item)) ;

How can I solve this problem?

Solution 1:

The Holo-theme rotation mode is the drop-down mode by default. And all moves with the standard style override simply switch to spinner mode in dialogue mode, so you can successfully wrap multi-line text like in api 11. Instead, you can create a spinner using the new spinner(context, Spinner.MODE_DIALOG) or in xml: android:spinnerMode=dialog. But that doesn’t solve the problem because it’s a dialog, not a drop-down list.

I’ve found another solution to this problem: Replace the getDropDownView method in the ArrayAdapter and putSingleLine(false) in the Display Post method. In this way, the completely created text is included in the correct lines when you display it.

@Update
public view getDropDownView(final int position, View convertView, ViewGroup older) {
if (convertView == null) {
convertView = new TextView(_context);
}.

TextView element = (TextView) convertView;
element.
finalItem = article;
article.post(new Runnable() {
@Override
public void run() {
finalItem.setSingleLine(false);
}.
});
thing back;
}.

UPDATE:

And here’s another answer.

Manually wrap the list view in a PopupWindow and display it in TextView with a single click and hide it in a listItem.

A simple execution, just to show the idea:

The public MySpinner class extends TextView {
private PopupWindow _p;
private ListView _lv;
public MySpinner(Context context) {
super(context);
init();
}
public MySpinner(Context context, attributeSet attributeSet){
super(context, attributeSet);
init();
}.

private void init(){
setBackgroundResource(R.drawable.spinner_background);
final list list = new ArrayList();
list.add(Very long text AAAAAAAAAAAAAAAAAAA);
list.add(1 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA);
list.add(2 Very long text A);
list.add(3 Very long text AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) ;

setMinimumWidth(100) ;
setMaxWidth(200) ;

_lv = new ListView(getContext());
_lv.setAdapter(new ArrayAdapter(getContext(), R.layout.simple_list_item_1, list)));
_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public null and void atItemClick(AdapterView adapterView, View view, int i, long l) {
_p.dismiss();
setText(list.get(i));
}
}) ;

setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view)) {

_p = new PopupWindow(getContext());
_p.setContentView(_lv);
_p.setWidth(getWidth());
_p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
_p.setTouchable(where);
_p.setFocusable(where);
_p.setOutsideTouchable(where);
_p.showAsDropDown(view);
}
});
}
}.

Solution 2:

Only the combination of solutions worked here for me (also tested on Android 5.1) :

spinner_item.xml

Code

final ArrayAdapter spinnerAdapter=new ArrayAdapter(activity,R.layout.spinner_item,android.R.id.text1,spinnerItemsList)
{
@Override
public view getDropDownView(final int position,final View convertView,final ViewGroup parent)
{
final View v=super.getDropDownView(position,convertView,parent);
v.post(new Runnable()
{
@Override
public void run()
{
((TextView)v.findViewById(android.R.id.text1))).setSingleLine(false);
}
});
return v;
}
};
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) ;

Solution 3:

I solved this problem by switching to a rotating dialogue style:

Solution 4:

It’s impossible to get multi-line dropdowns on spinners using the holothema from what I’ve tried.

A workaround is a workaround:

  • to create a style for spinners that wasn’t inherited from Holo. This makes it possible to create drop-down lists on different lines.
  • Draw the spinning top by hand to look like a holotem.

This creates (shows closed and open state) :

Give here a description of the image

Implementation details :

Taking over the holothema on the spinner and displaying multiple lines in the scrolling element of the spinner is, as far as I can see, not possible, although we do fake the TextView singleline attribute in the scrolling element and provide a custom layout. I’ve also tried to keep the holo-style, but I’ve changed…

android: spinnerStyle
android: spinnerItemStyle
android: spinnerDropDownItemStyle

Assign styles (example of use here), but I wasn’t able to get multi-line results.

However, if we ignore the style for spinning and do not inherit the SpinnerStyle from Holo :

then the scrolling element allows multiple lines to be displayed. But now we have lost the holothema in favor of rotation, and the closed state looks like a TextView instead of a rotation, without arrows or visual indications that it is a rotation. If you set the spinnerStyle parent instead to: parent=android:style/Widget.Spinner :

The closed state of the router shows an arrow, but looks like a gray PreHolo router that does not seem to fit in the Holo application.

So, a possible solution:

  • Cancel the theme for spinnerStyle and do not use the holo for parents. This allows you to display multiple texts in the drop-down elements.
  • Change the background of the router to make it appear as if it has inherited the holothema.

Here’s an example:

Creating a core business :

Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState) ;
setContentView(R.layout.activity_main) ;

Spinner spinner = (spinner)findViewById(R.id.styled_spinner) ;

spinner.setAdapter(ArrayAdapter.createFromResource.this,
R.array.items,
R.layout.spinner_item)));
}

Structure of activities :

Styles:

Place spinner_background_holo_light in the render folder :

and paste these drawings into your drawing board PDF folder:

Fill in the image description
spinner_default_holo_light.9.png

Enter the image description here
spinner_disabled_holo_light.9.png

Fill in the image description
spinner_focused_holo_light.9.png

Fill in the image description
spinner_pressed_holo_light.9.png

The result is a spinner with a closed holothema and multi-line elements, as can be seen in the screenshots above.

The drop-down lists in this example are not holistic, but this can be an acceptable compromise if the multiple display of drop-down lists is really important.

In this example, the android:minSdkVersion in the manifest is set to 14 and the android:targetSdkVersion is set to 17.

Holo graphics and spinner_background_holo_light.xml code are from HoloEverwhere Copyright (c) 2012 Christophe Versieux, Sergey Shatunov. See the section on the Github project for license information.

Solution No 5:

By adding a LinearLayout around a TextView, you can wrap the text correctly.

Layout (common_domainreferencemodel_spinner_item.xml) :

Adaptors :

The public class DomainReferenceModelAdapter extends the ArrayAdapter {

private List objects;
private LayoutInflater inflater;
private int oddRowColor = Color.parseColor(#E7E3D1);
private int evenRowColor = Color.parseColor(#F8F6E9) ;

public DomainReferenceModelAdapter(Context, int resource, List of objects) {
super(context, resource, objects);
this.objects = objects;
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}.

ImageStatic class holder {
public TextView nameTextView;
}

@Override
public view getView(int position, View convertView, ViewGroup parent) {
return getViewInternal(position, convertView, parent, false);
}

@Overview
public view getDropDownView(int position, View convertView, ViewGroup parent) {
return getViewInternal(position, convertView, parent, true);
}

private View getViewInternal(int position, View convertView, ViewGroup parent, boolean isDropdownView) {
view = convertView;
if (view == null) {
view = inflater.inflate(R.layout.common_domainreferencemodel_spinner_item, null);
viewHolder viewHolder = new ViewHolder();
viewHolder.nameTextView = (TextView) view.findViewById(R.id.nameTextView);
view.setTag(viewHolder);
}
if (isDropdownView) {
view.setBackgroundColor(position % 2 == 0 ? evenRowColor: oddRowColor);
}
viewHolder = (viewHolder) view.getTag();
DomainReferenceModel = objects.get(position);
holder.nameTextView.setText(model.getName());
return view;
}

}

Solution No 6:

I had the same problem. I want to see 2 lines in the spinner’s drop-down menu, but all the solutions I found seem to be insufficient to solve such a simple problem. I looked at the source code of the Spinner and found that if we use a custom .xml with the attribute android:singleLine=false.

and ArrayAdapter, the following code is executed by default in the ListPopupWindow each time

@Override
View More getView(int position, boolean[] isScrap) {
View View = super.getView(int position, isScrap) ;

if (Image of TextView instance) {
((Image of TextView)).setHorizontallyScrolling(true);
}

Rear view;
}

and so we only see one line at a time on the list, it actually rolls.

To solve such a problem, our view doesn’t have to be a TextView example, you simply place your TextView in a FrameLayout or LinearLayout.

и

ArrayAdapter = new ArrayAdapter (this,
R.layout.multiline_spinner_dropdown_item,R.id.multiline_spinner_text_view,
awasomeListValues) ;

This solution works in both turning modes: MODE_DROPDOWN and MODE_DROPDOWN.hope this helps you!

Solution No 7:

I think there’s a bug on Android. You can try that. Delete spaces from the text and then display them on the screen. If the representation length of the text is < string length, all characters after the space are ignored.
You can try this as a cure:

Add a file named multiline_spinner_dropdown_item.xml with sample code to the res/lay-out folder :

and when you make a dice, you make it from this layout.

Kind of like:

ArrayAdapter.createFromResource(this, items, R.layout.multiline_spinner_dropdown_item) ;

Basically, copy the android.R.layout.simple_spinner_dropdown_item layout into the project and change the layout by setting the singleLine attribute in CheckedTextView to false.

Solution No 8:

I did it to make it work:

ArrayAdapter Adapter = new ArrayAdapter(getContext(), R.layout.simple_dropdown_item_multiline, R.id.nameTextView, choice) ;

And this is the content of simple_dropdown_item_multiline :

Solution No 9:

I just found out that Android has an existing style for this.

final Spinner pelanggaran = (Spinner) findViewById(R.id.pelanggaran);
ArrayAdapter pelanggaran_adapter = ArrayAdapter.createFromResource(this,R.array.pelanggaran_array,android.R.)layout.simple_expandable_list_item_1) ;
pelanggaran_adapter.setDropDownViewResource(android.R.layout.simple_expandable_list_item_1) ;
pelanggaran.setAdapter(pelanggaran_adapter) ;

I hope this solves your problem.

Solution No 10:

ArrayAdapter specAdapter =
ArrayAdapter.createFromResource(
getActivity().getBaseContext(),
aa[position],
android.R.layout.select_dialog_item) ;
specAdapter.setDropDownViewResource(android.R.layout.select_dialog_item) ;

Good luck!

Related Tags:

autocompletetextview,multiautocompletetextview,android autocompletetextview custom adapter,android autocompletetextview dropdown style,autocompletetextview onitemselectedlistener,autocompletetextview with listview in android,android spinner selected item text color,android spinner text color is white,android-spinner background color,change spinner arrow color android,android spinner style,textinputlayout hint always on top,custom textinputlayout android github,customize textinputlayout android,text input layout validation android,how to import textinputlayout android,textinputlayout gradle,android-spinner multiline text,android-spinner wrap text

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Gordon James

Gordon James

James Gordon is a content manager for the website Feedbuzzard. He loves spending time in nature, and his favorite pastime is watching dogs play. He also enjoys watching sunsets, as the colors are always so soothing to him. James loves learning about new technology, and he is excited to be working on a website that covers this topic.

Related Posts

World Tech

No Phone, No Problem: Receiving SMS Online Made Easy

March 24, 2025
Image2
World Tech

The Smart Shopper’s Guide to Finding Reliable Tech at the Price

February 24, 2025
Image1
World Tech

The Unique Appeal of Clash GG Case Battles

February 19, 2025
Next Post

11 Best Google Hidden Games You Can Play 2021

10 Best Torrent Downloader Software

Easy Steps To Merge Two Images In Paint 3D On Win­dows 10

No Result
View All Result

Recommended

Image2

Build Smarter, Ship Faster: Why Agile Teams are Adopting Model Context Protocol

23 hours ago

Smart Transit: The Rise of GPS, Scheduling Apps, and Digital Tools in Bus Fleets

1 day ago
Image3

Why Social Betting is Changing Online Gambling’s Future

2 days ago
Image1

What $10 Purchase You in The Digital World: A 2025 Micro-Spending Roundup

4 days ago

Categories

  • Businesses
  • Fitness Trackers
  • Gaming
  • General
  • General News
  • Latest
  • Latest Trends
  • Online Gaming
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code

Our Address: 222 Haloria Crossing
Vrentis Point, HV 12345

Categories

  • Businesses
  • Fitness Trackers
  • Gaming
  • General
  • General News
  • Latest
  • Latest Trends
  • Online Gaming
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code
No Result
View All Result
  • Image2
  • Image1
  • Image2
  • RyanMotorsOmaha
  • Tech News FeedCryptobuzz
  • Ujjukt [Hjv
  • www Feedbuzzard .com
  • Image3
  • Image3
  • Image1
  • Image3
  • Image2
  • Image2
  • Image3
  • Image1
  • Image2
  • Image2
  • pandagendut slot
  • faktor-faktor yang mendorong didirikannya voc adalah
  • sayur yang bisa ngeramal
  • buku mimpi 2d 3d 4d abjad
  • gerakan awal guling lenting yang benar diawali dengan gerak
  • ibanking bank jateng personal
  • canadadry.ca enter pin 2022
  • chord gitar wali kerudung merah
  • Reparasi Tas Terdekat
  • buku mimpi 2d 3d 4d abjad
  • no hp janda yang bisa dihubungi
  • pola138
  • photoacampamente
  • bo togel hadiah 2d 200rb
  • www feedbuzzard .com
  • feedcryptobuzz cryptocurrency updates from feedbuzzard
  • feedbuzzard com
  • Ca Khia
  • 5 letter words starting with ca
  • Mobile. de
  • Mendarat Yang Baik Dalam Lompat Jauh Dilakukan Dengan.....
  • jual ayam potong terdekat
  • how to play crypto games in 2023 feedgamebuzz
  • latest gadjets for gaming zardgadjets
  • latest hacks buzzardcoding
  • what are new technologies in 2023 feedworldtech
  • Image1
  • remaxhd.com
  • tv.hotstar.com
  • rajbet.com
  • venus.happyreturns.com
  • Image2
  • ibooma.com
  • fapwife.com
  • Image1
  • Image1
  • Image3
  • Image2
  • the budget process involves doing all of the following except
  • rice purity test for 14 year olds
  • during operations outside declared hostilities, you may delay contact with local authorities.
  • rick and morty season 6 online
  • active shooter is one or more subjects who participate in a shooting
  • which of the following is most likely to be considered plagiarism
  • which of the following could be a replacement behavior for cutting in line
  • effective scrum master apply which coaching behavior
  • a decrease in blood protein concentration would tend to
  • hair removal cream for private parts male
  • what escape planning factors can facilitate
  • the adversary is collecting information regarding your organization's mission from the trash
  • identify two meanings for the japanese word inu
  • an immediate annuity has been purchased with a single premium
  • justify the following statement: “diversity should exist in the workplace.”
  • fc barcelona vs viktoria plzeň lineups
  • which of the following is tax-deductible to the firm?
  • latest feedbuzzard com
  • treasure of wisdom a new plan
  • which data types are typically found in the human resources department?
  • what supports the arms and hands medical term
  • which of the following is true about nonforfeiture values?
  • match each type of anxiety disorder with its description.
  • daniel is a middle-income medicare beneficiary
  • what does wtm mean on snapchat
  • which facility is shown in the image
  • how can you report potential insider threats to the js in to select all that apply
  • what does wtv mean in text
  • jane assessment answers
  • employee records must meet all of the following criteria except
  • a major challenge of nationalism is .
  • a covered entity (ce) must have an established complaint process. true false
  • fema is 100 hcb answers
  • identify the true and false statements about culture.
  • in which word does the grapheme representing /k/ indicate that the word is probably from greek?
  • mr. wingate is a newly enrolled
  • gear patrol the spirit of adventure
  • ms insurance company denied a reinstatement
  • which option below is a preventive measure against id fraud or theft?
  • preferred stock is advantageous in that it ______. (check all that apply.)
  • which sentence from the novel best reflects the story's gothic nature
  • m and t bank near me

© 2022 FeedBuzzard.com

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
No Result
View All Result
  • General
    • General News
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • Latest
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact

© 2024 JNews - Premium WordPress news & magazine theme by Jegtheme.