Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Dialog with modifiable single line title
    primarykey
    data
    text
    <p>In short, I'm working on a "DurationPickerDialog" that works similarly to how the DatePickerDialog works but works based on the <a href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#duration" rel="nofollow noreferrer">xsd:duration</a> type, so the user specifies the number of years, months, days, etc.</p> <p>I've also implemented a "fuzzy duration" function that gives me durations as a string like "one month ago". I would really like to be able to update the DurationPickerDialog's title in the same manner that the DatePickerDialog's title is updated, but there seems to be a problem. In the DatePickerDialog, they have it set to be a single line all the time, so that it doesn't get "jumpy." Here's how Android's source does the DatePickerDialog's title.</p> <pre><code>// Note: before the skim-readers look at this bit, realize that this is NOT my // code but Android's internal code for the DatePickerDialog. @Override public void show() { super.show(); /* Sometimes the full month is displayed causing the title * to be very long, in those cases ensure it doesn't wrap to * 2 lines (as that looks jumpy) and ensure we ellipsize the end. */ TextView title = (TextView) findViewById(R.id.alertTitle); title.setSingleLine(); title.setEllipsize(TruncateAt.END); } </code></pre> <p>Unfortunately, I cannot access their <code>R.id.alertTitle</code>, because it is part of <code>com.android.internal.R</code>. </p> <p>I have seen implementations like <a href="https://stackoverflow.com/questions/3578929/android-how-to-create-a-dialog-with-a-scrolling-title">this stackoverflow post</a> where it would have me modify the <code>Window.FEATURE_CUSTOM_TITLE</code> attribute, but that doesn't seem to let me modify the title (easily) after that.</p> <p>There was also <a href="https://stackoverflow.com/questions/820398/android-change-custom-title-view-at-run-time">another stackoverflow post</a> that mentioned how to change the title at runtime between two different XML layouts, but that also doesn't seem like it would be all too helpful, since the title should be modified every time the duration changes, and creating an XML layout for each duration is obviously not a good idea.</p> <p>So, since they "cheated" by accessing a value that us mere mortals don't have access to, is there another way that I could go about doing it?</p> <hr/> <p><strong>Edit:</strong> And through some black magic, it seems that it now <em>does</em> ellipsize the text like I was wanting? Only earlier it wasn't, and now I can't seem to reproduce the problem. So, I suppose while we're at it, can someone explain to me how I might have accomplished this magic?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload