Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

checking resources in xml and displaying icons for the resources in android -


hai every one. new android. in project had problems reading xml files. in xml have included audios , videos paths , want read xml file through code , want display images n view if there audio or video files. can body tel how read xml file. thanking in advance

ok first need create parser below code this:

public static void readtemplatefile(context context) {

    /**      include file checking      */      try {         xml_handler_template myexhan = new xml_handler_template();          inputstreamreader isr =  new         filereader( new file(environment.getexternalstoragedirectory().getpath() + "/library template.xml" ));          xml_handler_template.context = context;          saxparserfactory spf = saxparserfactory.newinstance();         saxparser sp = spf.newsaxparser();          xmlreader xr = sp.getxmlreader();          xr.setcontenthandler((contenthandler) myexhan);          xr.parse(new inputsource(isr));       } catch (exception e) {          toast.maketext(context, ">" + e.getmessage(), toast.length_long).show();       }  } 

you need handler class. in above example class called xml_handler_template.

filereader( new file(environment.getexternalstoragedirectory().getpath() + "/filepath/file.xml" ));

here xml_handler_class @ moment blank:

import org.xml.sax.attributes; import org.xml.sax.saxexception; import org.xml.sax.helpers.defaulthandler;

public class xml_handler_template extends defaulthandler{

    public static context context = null;  @override public void startdocument() throws saxexception {     //this called when document first read }  @override public void startelement(string namespaceuri, string localname,         string qname, attributes atts) throws saxexception {                     //this called when new tag opened                     //localname holds tag name, value got                      //characters function @ end of class                     //the attributes each tag stored in atts array, can either handle attribute values here or pass information separate function handle them,                    if (atts.getlength()>0){             (int i=0;i<atts.getlength();i++){                  addattrib(atts.getlocalname(i) , atts.getvalue(i))  ;              }         } }  @override public void endelement(string namespaceuri, string localname, string qname) throws saxexception {     //this called when tag closed }  @override public void enddocument() throws saxexception {                 //this called when document closed }  @override public void characters(char ch[], int start, int length) {             //this value of tag read     string value = new string( ch , start , length );             // may want include replaceall("\r","") , replaceall("\n","") remove hidden chars  }     

}

have play , see how on =0) passed context class whilst learning use toasts show me values being read.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -