android


Font change in textview in an activity


In my application i am displaying some data in an activity.If user clicks on 1 image the fontsize of the data should change.But in my case nothing is happening..I have set the data for this page using AdpaterClass.
My activity code:
public class NewsDescription extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.newsdescriptionrow);
Gallery gl=(Gallery)findViewById(R.id.GalleryNewsDesc);
NewsDescriptionAdapter adapter =new NewsDescriptionAdapter(this);
gl.setAdapter(adapter);
ImageView img=(ImageView)findViewById(R.id.fontimage);
TextView prevnews=(TextView)findViewById(R.id.prevnews);
prevnews.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("subbu");
}
});
img.setOnClickListener(new View.OnClickListener() ---------->this is the clicking part of the image.
{
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
System.out.println("Inside click");
}
});
}
}
My adpater class:
public class NewsDescriptionAdapter extends BaseAdapter
{
private static Context contxt;
String[] body= {};//new String[30];
String[] heading= {};//new String[30];
private Integer mImageIds = R.drawable.font;
int font = 10;
//
NewsDescriptionAdapter(Context conxt)
{
// System.out.println("inside cons");
this.contxt=conxt;
getelement();
}
public NewsDescriptionAdapter(OnClickListener onClickListener) {
System.out.println("prakashhh....");
font = 20;
getelement();
// TODO Auto-generated constructor stub
}
public void getelement()
{
String[] url=context.getInstance().getselectedUrl();
int count = Integer.parseInt((String)context.getInstance().getAppVariable("count"));
String URL = "http://m.indiatoday.in/xml/stories/"+url[count];
TaplistingParser parser = new TaplistingParser();
URL=URL.replace(" ","");
// System.out.println("url="+url);
String xml= parser.getXmlFromUrl(URL);
Document doc=parser.getDomElement(xml);
NodeList n1 = doc.getElementsByTagName("item");
body = new String[n1.getLength()];
heading = new String[n1.getLength()];
for( int i = 0 ; i < n1.getLength(); i++ )
{
// HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) n1.item(i);
body[i]=parser.getValue(e, "body");
heading[i]=parser.getValue(e, "headline");
// map.put("Body", parser.getValue(e,"body"));
// menuItems.add(map);
}
}
// }
#Override
public int getCount()
{
// TODO Auto-generated method stub
return body.length;
}
#Override
public Object getItem(int position)
{
// TODO Auto-generated method stub
return body[position];
}
#Override
public long getItemId(int position)
{
// TODO Auto-generated method stub
return position;
}
View rowView ;
int Position=0;
#Override
public View getView(int position, View convertView, ViewGroup parent)
{
this.Position=position;
// TODO Auto-generated method stub
rowView = LayoutInflater
.from(parent.getContext())
.inflate(R.layout.newsdescriptionrow, null); -------> This is the layout where that imageview is present.
TextView prevnews=(TextView)rowView.findViewById(R.id.prevnews);
TextView nextnews=(TextView)rowView.findViewById(R.id.nextnews);
ImageView img=(ImageView)rowView.findViewById(R.id.fontimage);
img.setImageResource(mImageIds);
prevnews.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
System.out.println("inside prev");
}
});
nextnews.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View arg0) {
System.out.println("inside next");
int count = Integer.parseInt((String)context.getInstance().getAppVariable("count"));
count ++;
context.getInstance().setAppVariable("count",Integer.toString(count));
// TODO Auto-generated method stub
}
});
TextView textViewhead = (TextView) rowView
.findViewById(R.id.name_DescHeading);
textViewhead.setText(heading[position]);
TextView textView = (TextView) rowView
.findViewById(R.id.name_Desclabel);
textView.setText(body[position]);
System.out.println("font="+font);
// textView.setTextSize(font);
textViewhead.setTextSize(Integer.parseInt((String)context.getInstance().getAppVariable("nd_heading_size")));
textViewhead.setTextColor(Integer.parseInt((String)context.getInstance().getAppVariable("nd_heading_color")));
// textViewhead.setTypeface(((String)context.getInstance().getAppVariable("nd_heading_size")));
textView.setTextSize(Integer.parseInt((String)context.getInstance().getAppVariable("nd_content_size")));
textView.setTextColor(Integer.parseInt((String)context.getInstance().getAppVariable("nd_content_color")));
// textView.setTypeface(tf);
return rowView;
}
}

Related Links

android.view.ViewRoot$CalledFromWrongThreadException in badge view
JSON to parse data into android application
Android draw() not triggered
Android: ListView background color when not enough items fill. [Screenshot]
Which libraries I need to create a websocket client in Android [closed]
Open New Activity From Withinside a Fragment Using a Button
Gridview numbering
How to get a ParseFile from JSONArray (retrieved from CloudCode parse.com) in Android
How to determine whether a device is handset or tablet using findFragmentById() method?
Phonegap application hides splashscreen too quickly
URL to Bitmap for PanoramaGL viewer
Android set layout depending screen size [duplicate]
Picture taken on portrait mode is saved rotated counter clockwise?
MenuItem actionView aligns right
Portrait mode gets misinterpreted as landscape when keyboard is on
How to change color of text when click in base adapter in android

Categories

HOME
google-app-engine
deep-learning
polymer
apache-jena
fpga
jsf-2.2
pclxl
database-normalization
aws-cli
3d-reconstruction
tvos
mvc5
modal-dialog
extjs4.2
commonjs
ibeacon-android
cmdb
spring-social
zerobrane
flash-player
symbol
package.json
job-scheduling
shortest-path
topology
google-maps-autocomplete
visual-glitch
handler
datastax-enterprise-graph
comparable
cppreference
userdefaults
jbutton
quickfixj
memory-address
android-gridview
hunspell
pop3
html-encode
imx6
playframework-2.1
dm-script
ideascript
z-notation
news
laravel-elixir
dbnull
sonarlint-eclipse
twilio-click-to-call
page-replacement
java-6
check-mk
rsa-archer-grc
change-tracking
hadoop-2.7.2
pacemaker
rspec2
model-associations
jclouds
cfchart
php-socket
kiosk
beanstalk
halcon
invoke-sqlcmd
lazybones
xvim
google-books
rubaxa-sortable
android-launcher
opserver
canalyzer
viola-jones
amiga
sha512
apache-commons-daemon
matlab-deployment
grouping-sets
metatrader5
iso-prolog
paw
cbind
wcm
menubar
qscrollarea
multitasking
http-patch
kendo-dataviz
rolify
tlf
nebula
time.h
dopostback
veracity
inkcanvas
azman
htdocs
timthumb
cuteeditor
tmx
undefined-index
updatesourcetrigger
openfaces
pagemethods
skype4java
fdf
java1.4

Resources

Encrypt Message