Android Tabwidget change Textview color programatically - android-tabhost

In below tabview layout contents how to get reference for each textview and change color, text programatically.?
For example i want to change RF1235678 textview color and text

#Vishwanath
TabSpec tab1 = tabHost.newTabSpec("First Tab");
TextView textView = new TextView(this);
textView.setText("exampletab");
textView.setTextColor(Color.BLUE);
tab1.setIndicator(textView);
tabHost.addTab(tab1);

Related

Accessibility Text Size affecting alignment in TableViewCell

When I change the text font size in the accessibility, one of the Table View Cell's title becomes left aligned instead of center aligned.
When turned off:
the table view cell button shows the text as it should (centered)
However, when the accessibility text size is set larger, like this:
The table view row cell shows title text of button left aligned:
I am using XLForm to create these buttons as rows with the XLFormRowDescriptor of XLFormRowDescriptorTypeImageButton
This is how I am defining this row:
let row = XLFormRowDescriptor(tag: FormTags.SubmitButton.rawValue, rowType: XLFormRowDescriptorTypeImageButton, title: "submit".localization())
styleRow(row: row)
configureImageRow(row: row, bgImage: UIImage(named: "greenButton")!, selectedBgImage: UIImage(named: "greenButton-pressed")!)
row.cellConfig["textLabel.textColor"] = UIColor.white
row.cellConfig["textLabel.numberOfLines"] = 1
row.cellConfig["textLabel.adjustsFontForContentSizeCategory"] = false
row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.center.rawValue
row.cellStyle = UITableViewCell.CellStyle.default
section.addFormRow(row)

why toolbar text color always white in SwiftUI project

I have a problem in my SwiftUI project. In toolbar text buttons color is white, even I add this code
init() {
UIToolbar.appearance().barTintColor = UIColor.red
}
there is not any change, I do not know why? Any idea?
You could set an accent color to the view like this:
.accentColor(Color.red)

How to automatically adjust the width of a centered UITextfield in Swift while editing?

I have a custom UITextfield that is x-centered to its superview via a constraint. It also has a height-constraint and a nice thin line right under the text that has the same width as the textfield itself (like I said: custom).
I now want to keep the UITextfield centered while editing its content, adjusting itself in width to its string content.
What right now happens is that it keeps its width while editing, cropping its overlapping content.
My code is kind of
// on textfields editing change event
#IBAction func nameFieldEditingChanged(sender: AnyObject) {
// set width of textfield to width of textstring
checkUserNameTextfieldWidth()
}
func checkUserNameTextfieldWidth(){
println("checkUserNameTextfieldWidth \(userName.text) / \(userName.frame.size.width) / \(view.bounds.width)")
// something has to happen here I guess...
}
Thnx!
You have to use UITextView instead of UITextField and apply its sizeThatFits method (see this response)

cocoa - what happen when close a window (by pressing the red X button)?

I'm writing an app for MacOS to display a string to a NSTextfield in a window when user click on the button in the status bar menu (application is an agent). The thing is I want to use the NSScrollView to embrace that NSTextview so that the NSTextview is scrollable. It sound simple but some thing happen:
(1) When I click the button on the menu, the window appear using the NSWindowController.showWindow(). But if the string is large (larger than the clipview), the NSScrollView isn't scrollable. If I select the text inside, then I can select the rest of the text that doesn't appear in the clipview
(2) If I leave the window there and click to the button again, then the the text is scrollable and the scrollbar appear!
(3) If I close the window by click on the red X button on top-left, then click to the button, then the window appear with the same situation at first (isn't scrollable). Notice that I don't recreate the new instance of NSWindowController of the window, at this time I just do the showWindow() with the old instance of the NSWindowController
This is the code:
if(newWC.window == nil){
let storyboard = NSStoryboard(name: "Main", bundle: nil)
newWC = storyboard?.instantiateControllerWithIdentifier("newWC") as! NewWindowController
newWC.window?.level = kCGStatusWindowLevelKey
println("new window")
}
newWC.showWindow(self)
//This is the ViewController contain the NSScrollView and the TextField
manualCopyView = newWC.window?.contentViewController as! ManualCopyViewController
var theScrollView = manualCopyView.theScrollView
var manualTextField = manualCopyView.manualEditTextField
//Calculate height of a block of string
manualTextField.stringValue = totalString.stringByAppendingString("")
var textFieldHeight = (manualTextField.cell() as! NSTextFieldCell).cellSizeForBounds(NSMakeRect(0, 0, 448, CGFloat(FLT_MAX))).height
if(textFieldHeight < 200){
textFieldHeight = 200
}
var frame = manualCopyView.manualEditTextField.frame
var clipViewFrame = theScrollView.contentView.frame
frame.size.height = textFieldHeight
//Change the frame of the textfield to fit the content string
manualTextField.frame = frame
//Gain focus to the new window
NSApp.activateIgnoringOtherApps(true)
It look like when the window first appear (or re-appear), the NSTextField is shrink even that I changed it's frame. But if I don't close it and show the window again, the frame expand as expected
I also used auto layout with constraints in the width and height of the scrollview and the width and minimum height (>= 200) of the textfield (because I think the height would be expanded)
Another question in this case: I have to set the scrollview Vertical Elasticity to No Elasticity or even the second case won't work. Is that normal?
Thank for any help.

UIButton's textLabel not being clipped

I have a UIButton,and I set its text like this:
let myButton ...
myButton.textLabel?.text = "abcdefghijklmn"
But when I run it ,the text is clipped. How could UIButton auto resize to fit its inner text.
Here is the screenshot.
What I want is this:
abcdefghijklmn
Option A: myButton.sizeToFit()
Option B: use layout constraints that don't constrict the label's width