and i don't know it is possible to do what i want.. (sorry for my english)
<TableRow>
<Button
android:id="@+id/button_left"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:onClick="moveLeft"
android:layout_column="1"
android:background="@drawable/bt_left"/>
<com.pauza.simpletetris.MyView
android:id="@+id/my_view"
android:layout_width="250dp"
android:layout_height="490dp"
android:layout_gravity="center_horizontal"
android:layout_column="2"
android:orientation="vertical"/>
from here i call MyView, but in MyView Button_Left not exist. Game activity:
public class GameActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
Button bt_right=(Button)findViewById(R.id.button_right);
Button bt_left=(Button)findViewById(R.id.button_left);
bt_right.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
moveRight();
}
});
bt_left.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
moveLeft();
}
});
}
protected void moveLeft() {
// TODO Auto-generated method stub
Toast.makeText(this, "You clicked left", Toast.LENGTH_LONG) .show();
}
private void moveRight() {
//call function from com.pauza.simpletetris.MyView <-- possible????
}
I hope you understand what i mean, thank you for everything.