Code example for Button

Methods: getTextsetText

0
			@Override 
			public void onClick(View v) {
				Button btn = (Button)v;
				 
				//if the text says 'start data pull', then start the AsynTask to fethc the data 
				if(btn.getText().toString().trim().equals("Start Data Pull")){
					netTask= new NetTask();
		    		netTask.execute();
					pv.setVisibility(View.VISIBLE);
					result_tv.setText("fething data from http://www.google.com");
					btn.setText("Stop Data Pull");
				}else if(btn.getText().toString().trim().equals("Stop Data Pull")){ //if the text says 'stop data pull' then stop the AsyncTask
					if(null!=netTask){
						netTask.cancel(true);
					} 
					btn.setText("Start Data Pull");
				}else if(btn.getText().toString().trim().equals("Clear")){ //If the text says 'clear' then clear the textview that holds the results
					result_tv.setText("");
					btn.setText("Start Data Pull");
				} 
			} 
		}); 
    } 
     
Connect your IDE to all the code out there  Get Codota for Java