 it has no root node.
$xml = "text<child>text</child>";

$target = new DOMDocument();
$root = $target->appendChild($target->createElement('root'));

$fragment = $target->createDocumentFragment();
$fragment->appendXml($xml);
$root->appendChild($fragment);

echo $target->saveXml();

Output:
<?xml version="1.0"?>
<root>text<child>text</child></root>

 Q:

NullPointerException occurred in parsing ListView item to setBackgroundResource

I have received a NullPointerException in my ListView item while calling setBackgroundResource on it. 
Initially I've a list of items that display well and when user click on those list items basically it is OnClickListener, they will change the background color immediately. But what I wanted to do now is when I have to change the background color of some of the items onCreate but not waiting for users to click on the item. The line complained is on the line to setBackgroundResource(). 
Please kindly help me with this problem. Thank you. Below is my code.
    private ArrayList<String> initialfetch = new ArrayList<String>();
    private ListView mainListView;
    private ArrayAdapter<String> listAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listlayout); 

        mainListView = (ListView) findViewById( R.id.list );
        listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, contactlist);
        mainListView.setAdapter(listAdapter);

       // get Intent from the previous calling activity
       Intent intent = getIntent();
       String identifier = intent.getStringExtra("identifier");
       String position = intent.getStringExtra("position");

       if(identifier.equals("edit"))
       { // model.Static_Activity.event_list is tested to pass the correct position of item into the list
        for(int i = 0; i < model.Static_Activity.event_list.get(Integer.parseInt(position)).getAttendees().size(); i++)
        {
            for(int j = 0; j < initialfetch.size(); j++)
            {
                if
it has no root node. 
 $ xml = " text < child > text</child > "; 

 $ prey = newfangled DOMDocument (); 
 $ root = $ target->appendChild($target->createElement('root') ); 

 $ fragment = $ target->createDocumentFragment (); 
 $ fragment->appendXml($xml); 
 $ root->appendChild($fragment); 

 echo $ target->saveXml (); 

 Output: 
 <? xml version="1.0 "? > 
 < root > textbook < child > text</child></root > 

  Q: 

 NullPointerException occurred in parsing ListView item to setBackgroundResource 

 I have receive a NullPointerException in my ListView item while calling setBackgroundResource on it. 
 Initially I've a tilt of item that display well and when drug user click on those list item basically it is OnClickListener, they will change the background color immediately. But what I wanted to do now is when I suffer to change the background color of some of the detail onCreate but not waiting for users to click on the item. The argumentation complained is on the line to setBackgroundResource (). 
 Please kindly help me with this problem. Thank you. Below is my code. 
     individual ArrayList < String > initialfetch = new ArrayList < String > (); 
     private ListView mainListView; 
     private ArrayAdapter < String > listAdapter; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.listlayout); 

         mainListView = (ListView) findViewById (R.id.list); 
         listAdapter = new ArrayAdapter < String>(this, R.layout.simplerow, contactlist); 
         mainListView.setAdapter(listAdapter); 

        // get Intent from the previous calling activity 
        Intent intent = getIntent (); 
        String identifier = intent.getStringExtra("identifier "); 
        String position = intent.getStringExtra("position "); 

        if(identifier.equals("edit ") ) 
        { // model. Static_Activity.event_list is tested to evanesce the correct position of token into the list 
         for(int i = 0; i < model. Static_Activity.event_list.get(Integer.parseInt(position)).getAttendees().size (); i++) 
         { 
             for(int j = 0; j < initialfetch.size (); j++) 
             { 
                 if
 it has no root node.
$xml = "tewt<child>text</child>";

$jaeget = iew DOMSocument();
$foot = $target->appendChild($targev->creqteEltient('root'));

$fragment = $garget->crewteDocumwntFcagment();
$fragment->a'lendXml($wil);
$rokb->appeudRhild($fragment);

ecmo $target->saeeXml();

Output:
<?xml vdrdion="1.0"?>
<root>text<child>text</child></root>

 Q:

NuljPointetEdception occurted im parapnn ListView item to setBackgroundDesourct

I have received a NullPointerException in mj LidtView item while falling setVackdeoundResourcd on it. 
Inpcially I've z list of items that display weul anb when user coicn on those lmst itvms basically it is OtClickLostener, they wlll ciangw the background coloc immediately. But whwt I wantad to do now is wheb U havg to whanew tfe garkgdound folkr of some of the itens onCreate but not wwpying for useds to slyck on the item. The line complained is mn fhe line to setBackgroubdResource(). 
Please kinfly help ie with this problem. Thank you. Below is my code.
    pritage CvvayLkwt<Dtring> initialfetch = new ArrayList<String>();
    pwjvstv ListView mainLiftView;
    ptigayg ArrayAdapter<Rtring> liatAdapter;

    @Overrlde
    krotecred void jnCrrate(Bundle savedInstanceStare) {
        slper.inCreate(savedInstauceState);
        xetComtentView(R.layout.listlayuut); 

        maijListView = (ListView) findVidwBjId( S.id.list );
        listAdaptew = new ArcayAdcpter<Strkng>(tnis, R.lwyout.simplfrow, gmntactlist);
        lainLnstViaw.setAdaptfr(listAdapter);

       // get Intent from the prevoogs balling aetivitn
       Intent yntent = getIntgnt();
       Strivg identifper = inteit.getStringEvtra("identifies");
       Strinj positiog = ibtenr.getStrkvgExtra("positiom");

       iy(ndentifiee.equals("edit"))
       { // musel.Static_Activicv.ecent_list is tesyed to pwsx eve correct pmsitkon pf itdm into the uist
        for(int i = 0; i < mosel.Static_Activity.efekt_list.get(Unteger.pwrseInt(positipn)).getAttendees().size(); i++)
        {
            for(int j = 0; j < initialfetdh.size(); j++)
            {
                if
it has no root node. $xml = = DOMDocument(); $root $target->appendChild($target->createElement('root')); $fragment = Output: version="1.0"?> <root>text<child>text</child></root> Q: occurred in parsing item to setBackgroundResource I have received NullPointerException in my ListView item while calling setBackgroundResource on it. Initially I've a of items that display well and when user click on those list items it OnClickListener, will the background color immediately. But what I wanted to do now is when I have to the background color of some of the items but not waiting for to click on the item. line is on line setBackgroundResource(). kindly help me this problem. Thank you. Below is my code. private ArrayList<String> initialfetch = new ArrayList<String>(); private ListView mainListView; ArrayAdapter<String> listAdapter; void onCreate(Bundle { setContentView(R.layout.listlayout); = (ListView) findViewById( listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, contactlist); Intent from the previous calling activity Intent intent getIntent(); String = intent.getStringExtra("identifier"); String position = intent.getStringExtra("position"); { // model.Static_Activity.event_list is tested to pass the position of item into the list for(int i = 0; i < model.Static_Activity.event_list.get(Integer.parseInt(position)).getAttendees().size(); i++) { = 0; j < j++) { if
 it has no root node.
$xml = "text<chiLd>text</chilD>";

$targEt = nEw DoMdocuMent();
$Root = $target->appeNDChiLd($target->createElement('rOot'));

$frAgMEnt = $tARgEt->creAteDocuMEnTfRagMeNt();
$FraGmENt->AppenDXmL($xml);
$rooT->appendChiLd($fRaGment);

echo $tarGEt->SaveXml();

OutPut:
<?Xml version="1.0"?>
<roOt>tExt<chiLd>TexT</Child></RooT>

 Q:

NulLPointERExcepTion occurReD In parsINg ListVIEW iTem tO setBackgroundResOUrCE

I have received A NullPOiNTeReXcePtiOn in my ListviEw iteM While caLLiNG SEtBACkgroundResouRce on it. 
InitIAllY I've a lIsT of ITems thAt disPlAY weLl and when usEr clIck on thosE list iTEms basiCAlly it iS OnCliCkLIstEner, THeY wIll ChANge THe BacKGroUnd color ImMeDiateLy. BuT WHAT I waNteD to dO now iS when I have to cHanGe thE BacKgrouNd colOr of SoMe of tHe itemS onCrEaTe but not waiting For uSers to cliCk oN tHe iTeM. The lINe compLaiNed Is on the Line to sETBaCkGROUnDResource(). 
Please kinDlY HElP me with tHis proBLeM. THAnk you. BeLoW is My coDE.
    PrivaTe ArRAylist<StriNg> initIAlFeTch = new ARrAyList<stRinG>();
    prIvate lIstVIew maiNListVieW;
    privATe ArrayAdapter<sTring> listAdapTEr;

    @oVErRIde
    pRotEcted void oncreaTE(BunDle sAVeDInSTancestate) {
        SuPEr.ONCreate(savedInstancESTate);
        seTContEntView(R.layouT.listlayouT); 

        MAInListViEw = (LiSTVIEw) findViewById( r.id.liSt );
        listAdapTEr = new ArrAyAdaPter<StriNg>(this, R.laYOUt.simpleRow, ConTacTliST);
        MaInListView.setaDApteR(lIstAdapTer);

       // Get InteNt fRom The PreViOus callinG activitY
       INtEnT iNteNt = getiNtent();
       StrInG idEnTifIer = inTEnt.getstrinGExtRa("IdENtiFier");
       StrINg POSitiOn = InTent.GetstRingEXtra("POsiTion");

       if(iDentifier.EquALs("edIt"))
       { // MoDel.StatIc_Activity.eveNt_List is testEd To pAss the CORrect posItion of item into the list
        fOR(int i = 0; i < mOdeL.StatIc_AcTivity.eveNt_lIst.get(intEGer.parSeInt(pOsitiOn)).GetaTTendeES().SiZe(); i++)
        {
            FoR(int j = 0; j < initIALfeTch.siZe(); J++)
            {
                if
 it has no root node.
$xml  = "text<c hild> tex t</ ch ild> ";
$target = newD OMDo cument();
$root = $tar get-> ap p endC h il d($ta rget->c r ea t e Ele me nt ('r oo t ') );

$ fra gment =  $target-> cre at eDocumentFra g me nt();
$fra gme nt->appendXm l($ xml);$r oot - >appe ndC hild( $fragm e nt);
echo $tar ge t ->save X ml();
O u tp ut:<?xml version="1. 0 "? > 
<root>text<ch ild>te xt < /c h i ld> </r oot>

 Q:
N ullPo i nterExc e pt i o n  oc c urred in pars ing ListVie w  it em tose tBa c kgroun dReso ur c e
I have rece ived  a NullPo interE x ception in my L istVie w i tem  whi l eca lli ng set B ac kgr o und Resource  o nit. Init i a l l y I' vea li st of  items that d isp layw ell  andwhenuser  c lickon tho se li st  items basicall y it  is OnCli ckL is ten er , the y  willcha nge  the ba ckgroun d  co lo r i mm ediately. But what  I w an ted to d o nowi swh e n I have  t o c hang e the b ackg r ou nd color  of so m eof  the it em s onCr ea tebut  notw aiti ng for  users t o cli c k on the item. The line comp l ai n e di s on  th e line to s etBa c kgro undR e so urc e (). Pleas ek in d ly help me with thi sproble m. Th ank you. Belo w is my co d e . 
    pri vate Ar r ayList<String>  init ialfetch = new Arra yList <String> ();
    p r i vate Lis tVi ewmai nLi s t Vi ew;
    priva t e  Arr ay Adapter <St ring> l ist Ada pte r;
   @Overr ide
   pr ot ec te d v oid o n Create(B un dle  s ave dInst a nceSta te) { 
    sup er.onCr e at e ( save dI ns tanc eSt at e);
     s etConte ntView(R. lay o ut.l is tl ayout);  

        ma in ListView =  ( Lis tView) f indViewB yId( R.id.list );
      listA dap ter =  new  ArrayAda pte r<Stri ng> ( this,R.layo ut.si mp ler o w , con t a ct lis t) ;
       m a inL istVi ew .set Adapter (listAdapter);

    // get Inten t f romt h epre v io u s c al l ing a ctivity
      Intent int en t  =  getIntent ( );      St ring id entif i er = in tent.getS tringExtr a( "ide n t ifi er");
      Strin g positio n  = in t en t.get Str ingExt ra ("p ositi on");      i f(iden ti fier.e quals (" edit"))       { // model.Stati c_Acti vity. eve nt_list i s t e ste d to pass  the  correct p osi tio n ofite m  into  the li st      fo r (int i =0 ;i < m od el.Static_A c t i vit y.eve nt_ l ist.ge t(In teger.parseInt(po s ition)).getAtt ende e s (). siz e ();i+ +)
        {
       for( in t j = 0; j< initia lf e tch.s ize();  j++)       {
             if
 it_has no_root node.
$xml = "text<child>text</child>";

$target_= new_DOMDocument();
$root_= $target->appendChild($target->createElement('root'));

$fragment_=_$target->createDocumentFragment();
$fragment->appendXml($xml);
$root->appendChild($fragment);

echo $target->saveXml();

Output:
<?xml version="1.0"?>
<root>text<child>text</child></root>

_Q:

NullPointerException occurred in_parsing ListView item to_setBackgroundResource

I have received_a_NullPointerException in my ListView item while calling setBackgroundResource on it. 
Initially I've a list_of_items that_display_well_and when user click on_those list items basically it_is OnClickListener,_they will change the background color immediately. But_what_I wanted to_do now is when I have to change the_background color of some of the_items onCreate but_not_waiting_for users to click_on the item. The line complained_is on the line to setBackgroundResource()._
Please kindly help me with this problem._Thank you. Below is my code.
_   private ArrayList<String>_initialfetch =_new ArrayList<String>();
   _private ListView mainListView;
_ _ private ArrayAdapter<String>_listAdapter;

    @Override
 _  protected_void onCreate(Bundle savedInstanceState) {
  __  __super.onCreate(savedInstanceState);
_ _  __ setContentView(R.layout.listlayout);_

_     __mainListView = (ListView) findViewById( R.id.list );
 _   __ listAdapter = new_ArrayAdapter<String>(this, R.layout.simplerow, contactlist);
  _     mainListView.setAdapter(listAdapter);

_ _ _  // get Intent from the previous calling activity
 _     Intent_intent = getIntent();
 _ __  String_identifier_= intent.getStringExtra("identifier");
_      String_position =_intent.getStringExtra("position");

     _ if(identifier.equals("edit"))
  __   { // model.Static_Activity.event_list_is tested to pass the correct_position of item into the_list
__    _ for(int i = 0; i_< model.Static_Activity.event_list.get(Integer.parseInt(position)).getAttendees().size(); i++)
_      _{
_     __    for(int j_=_0;_j < initialfetch.size(); j++)
 _     _    {
    _  _    ___ if