So essentially having trouble understanding the uses of the 'this' keyword in java. Have read around five tutorials, albeit not very good ones. Could someone quickly explain how it's used in relation to the following code? This is an android, it's assigning an xml button (btn_confirm) to b with Button type.
Button b = (Button)this.findViewById(R.id.btn_confirm);
b.setonclickListener(this);
Full Code:
public class dic_tut2 extends Activity implements onclickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)this.findViewById(R.id.btn_confirm);
b.setonclickListener(this);
}
public void onclick(View v) {
TextView tv = (TextView)this.findViewById(R.id.tv_welcome);
EditText et = (EditText)this.findViewById(R.id.txt_name);
String text = "Hello, " + et.getText().toString() + ".\n\n";
text += "Welcome to android development. :)";
tv.setText(text);
}
}