Android 2.3.3: Crash when getting a LinearLayout from (LinearLayout)findViewById(R.id.<linear_layout_id>)
===

I am programming a twitter app. I am making a search bar for usernames/hashtags, and I am having some trouble adding views generated from XML to the currently existing LinearLayout.

here is Search.java

    public class Search extends Activity{

	String searchType = "username";
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        
        EditText t = (EditText)findViewById(R.id.search_content);
        t.setOnClickListener(onClickSearch);
        t.setWidth(225);
        
        Button b = (Button)findViewById(R.id.search_button_search);
        b.setOnClickListener(onClickButton);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_search, menu);
        return true;
    }
    
    OnClickListener onClickSearch = new OnClickListener(){

		public void onClick(View v) {
			EditText searchContent = (EditText)findViewById(R.id.search_content);
			EditText clickedContent = (EditText)v;
			if((EditText)findViewById(R.id.search_content) == (EditText)v){
				EditText t = (EditText)v;
				t.setText("");
			}
			
			//EditText searchContent = (EditText)findViewById(R.id.search_content);
			//EditText clickedContent = (EditText)v;
			
			/*if((Button)v == (Button)findViewById(R.id.search_button_type)){
				EditText t = (EditText)findViewById(R.id.search_content);
				Search.this.searchByUserName(t.getText().toString());
			}
			
			if((Button)v == (Button)findViewById(R.id.search_button_search)){
				
			}*/
		}
    	
    };
    
    OnClickListener onClickButton = new OnClickListener(){

		public void onClick(View v) {
			//if((Button)v == (Button)findViewById(R.id.search_button_search)){
				EditText t = (EditText)findViewById(R.id.search_content);
				Search s = new Search();
				s.searchByUserName(t.getText().toString());
			//}
			
			//if((Button)v == (Button)findViewById(R.id.search_button_search)){
				
			//}
		}
    	
    };
    
    public void searchByUserName(String userName){
    	//System.out.println("beginning->searchByUserName");
    	TwitterHandler handler = new TwitterHandler();
    	List<View> views = handler.queryUserName(userName, this);
    	
    	LinearLayout ll = (LinearLayout)findViewById(R.id.search_panel);
    	for(int i = 0; i < views.size(); i++){
    		ll.addView(views.get(i));
    	}
    }
}

here is the XML

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/search_panel" >
        <Button
           android:id="@+id/search_button_type"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Search Type"/>

        <EditText
            android:id="@+id/search_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Search Here" >
        </EditText>
        
        <Button
            android:id="@+id/search_button_search"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Search"/>
    </LinearLayout>

My LogCat is telling me there is a NullPointerException, the process is forced to quit on the android virtual device. Please Help!!!

Here is the TwitterHandler

    public class TwitterHandler extends DefaultHandler{
	private final String USER_SEARCH = "https://api.twitter.com/1/users/lookup.xml?screen_name=";
	
	public List<View> queryUserName(String userName, Context context){
		System.out.println("beginning->queryUserName");
		String url = USER_SEARCH + userName;
		//ListView view = new ListView(context);
		List<View> views = new ArrayList<View>();
		Document doc = null;
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		try {
			System.out.println("in try statement->queryUserName");
			DocumentBuilder db = dbf.newDocumentBuilder();

			InputSource is = new InputSource();
	        is.setCharacterStream(new StringReader(url));
	        doc = db.parse(is); 
		
			NodeList nl = doc.getChildNodes();
						
			for(int i = 0; i < nl.getLength(); i++){
				Element e = (Element)nl.item(i);
				TextView t = new TextView(context);
				
				String name = "";
				String screenName = "";
				Bitmap bitmap = null;
				
				Node n = (Node)e.getChild("name");
				name = n.getTextContent();
				t.setText(name);
				views.add(t);
				
				t = new TextView(context);
				n = (Node)e.getChild("screen_name");
				screenName = n.getTextContent();
				t.setText(screenName);
				views.add(t);
				
				n = (Node)e.getChild("profile_image_url");
				bitmap = getBitmap(n.getTextContent());
				ImageView imageView = new ImageView(context);
				imageView.setImageBitmap(bitmap);
				views.add(imageView);

			}
			
		}catch(Exception e){ }
		return views;
	}
	
    private Bitmap getBitmap(String imageUrl) throws IOException{
	InputStream inputStream = null;
	 URL u = new URL(imageUrl);
	 URLConnection conn = u.openConnection();
	
	 try{
		  HttpURLConnection httpConn = (HttpURLConnection)conn;
		  httpConn.setRequestMethod("GET");
		  httpConn.connect();
	
		  if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
			  inputStream = httpConn.getInputStream();
		  }
	 }
	 catch (Exception ex) { }
	 
	return BitmapFactory.decodeStream(inputStream);

    }

    }
