android


Dynamic edittext not showing up text in an Android app


Creating a dynamic EditText as follows
EditText myText = new EditText(this);
myText.setId(ctrlKey);
myText.setBackgroundResource(R.drawable.style_edittext);
myText.setClickable(true);
myText.setCursorVisible(true);
myText.setTextColor(Color.BLACK);
myText.setTextSize(12);
myText.setText("may i"); //pageField.getValue());
myText.setSelection(0);
myText.setCursorVisible(true);
if (pageField.getMultiline()) {
myText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
else
myText.setSingleLine(true);
//myText.setEnabled(false);
pageLayout.setLayoutParams(ctrllp);
pageLayout.addView(myText, ctrllp);
Edittext is created and visible at appropriate location, but I can't see the text in the Edittext, and when I try a place cursor in it, it seems like there is already text in the Edittext (the cursor position and help words shown below confirms). Even if I type something in the Edittext also not visible.
XML
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.topazsystems.pdoc.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<include
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="#layout/toolbar" />
</android.support.design.widget.AppBarLayout>
<com.topazsystems.pdoc.ZoomableViewGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity = "center_horizontal|center_vertical"
android:id="#+id/zoomLayout"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill"
android:id="#+id/RelLayout">
<include layout="#layout/content_main" />
</RelativeLayout>
</com.topazsystems.pdoc.ZoomableViewGroup>
<include layout="#layout/fragment_navigation"/>
</android.support.design.widget.CoordinatorLayout>
In activity oncreate I am calling a method which contains the control rendering code.
pageLayout = (RelativeLayout) findViewById(com.topazsystems.pdoc.R.id.RelLayout);
//to display page controls during appload
pageControlsList = pdfRenderer.GetPageControls();
if (pageControlsList != null) {
if (pageControlsList.size() > 0) {
generateControls();
//fillDefaultDocControls();
mfrg.showPage(pdfRenderer.getmCurrentPageNum(), true, this);
}
}
where generatecontrols() contains the edittext creation code and mfrg is instance of fragment.
Check once removing background resource if it is the culprit. so remove the following line and check if text is visible.
myText.setBackgroundResource(R.drawable.style_edittext);
You have passed wrong context in EditText , you need to pass context of parent of EditText like below code.
in your code you are added EditText into pageLayout.
EditText myText = new EditText(pageLayout.getContext());

Related Links

how to load texture for meshes (not a3d object!) in renderscript?
Implementing Facebook App so that Android/iOS app can be easily generated [closed]
Adding android:configChanges to generated manifest
How do i setup android webdriver to work with selenium grid?
Is it possible to get a byte buffer directly from an audio asset in OpenSL ES (for Android)?
Grayscale PictureDrawable
How to get a textfield in android in this format?
Android app displaying a gif
Check if a thread is running from the “mother” class
Android: how to ignore rotation around single axis?
how to make keyboard go away when enter is press
Sum all the display values
To add the attachment to email
How to find memory leak using Memory Analyzer in android?
Generating activities Dynamically
How to remove gps updates after app was closed

Categories

HOME
gridview
jpa
hyperlink
merge
rdbms
toolbox
obfuscation
sitecore
requirements
appcelerator
google-admin-sdk
google-cloud-datalab
missing-data
activecollab
angular-dart
stellar.js
intercom
comsol
eip
http-post
gruntfile
dreamweaver
red5
soci
symfony-console
sse
connector
asp.net-core-webapi
selinux
ember-cli
angular-routing
pchart
highstock
mount
pic32
gpio
mat
android-maps
spotipy
testcomplete
weather
instantiation
classcastexception
hibernate-search
html-encode
fiware-cygnus
latitude-longitude
docfx
git-rewrite-history
demo
google-data-api
p4merge
c9.io
mcustomscrollbar
trigonometry
levenshtein-distance
congestion-control
placeholder
stylecop
uiimage
flask-restful
openal
dbcontext
launchctl
check-mk
lsyncd
mathcad
baidu
change-tracking
angular2-testing
builtins
google-cloud-console
android-dateutils
observablecollection
cassia
libvlc
vhosts
boomerang
java-money
xenomai
wiredep
dulwich
dnssec
uvc
public-html
rapidsvn
machine-instruction
rmysql
xml-namespaces
ora-00904
functional-java
hibernate-entitymanager
sphinxql
mbunit
poker
composite-component
video-codecs
onload-event
alice
argouml
resource-management
rmiregistry
procedures
role
expression-blend-4
landscape-portrait
clrstoredprocedure
massive
eclipse-marketplace
qtabbar
software-lifecycle
linfu-dynamicproxy
java1.4
xslcompiledtransform
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App