title: Fragment mysql database connection
body: <p>This is my fragment and i have database adapter,but the listview doesnt get populated.</p>
  
  <p>Here is my Code :</p>
  
  <p>public class HomeFragment extends Fragment {</p>
  
  <pre><code>public HomeFragment(){}
  
  private TextView txt;
  private String n = "";
  public String s="";
  public ListView lst;
  public Button btn;
  private HomeAdapter adapter;
  private List&lt;homeinfo&gt; items;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState)
  {
  
      View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
  
     lst=(ListView) rootView.findViewById(R.id.listView);
     btn=(Button) rootView.findViewById(R.id.button1);
  
     btn.setOnClickListener(new OnClickListener() 
     {
  
      @Override
      public void onClick(View arg0) 
      {
          // TODO Auto-generated method stub
          Intent intentDemo=new Intent(getActivity(),Testing.class);
          startActivity(intentDemo);
      }
  });
  
  
     items=new ArrayList&lt;homeinfo&gt;();
     adapter=new HomeAdapter(getActivity().getApplicationContext(),items);
     lst.setAdapter(adapter);
  
  
  
  
     Thread thread=new Thread(doInBackground);
      thread.start();
  
  
      return rootView;
  }
  </code></pre>
  
  <p>Runnable doInBackground=new Runnable()
       {</p>
  
  <pre><code>    @Override
      public void run() 
      {
          items = homeservice.getAllRadio("http://********.com/");
          runOnUiThread(runOnUi);
      }
  
   };
  
   Runnable runOnUi=new Runnable()
   {
  
      @Override
      public void run() 
      {
          for(homeinfo radioitems:items)
          {
              adapter.add(radioitems);
          }
  
          adapter.notifyDataSetChanged();
      }
  
   };
  </code></pre>
  
  <p>protected void runOnUiThread(Runnable runOnUi2) {
          // TODO Auto-generated method stub</p>
  
  <pre><code>}
  </code></pre>
  
  <p>}</p>