I have an Activity which has a method, I would like to call the entire method including buttons and other findViewById
objects such as layouts, I have tried the following but the app crashes with runtime/check_jni..
Anyway below is the code:
ButtonClass:
public class BottomButtons extends MainActivity {
ImageButton iconHideView;
boolean fl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.class_bottom_buttons);
}
public void bottomButtons() {
final LinearLayout ll = (LinearLayout)findViewById(R.id.bottomButtons);
final ScrollView sv = (ScrollView)findViewById(R.id.L_scrollView);
iconHideView = (ImageButton) findViewById(R.id.icnHideView);
iconHideView.setImageResource(R.drawable.arrow_down);
iconHideView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!fl) {
ll.animate().translationY(ll.getHeight()).alpha(0.0f).setDuration(1200).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
....
MainActivity Class (And All Other Activities):
public class MainActivity extends Activity {
BottomButtons classBB = new BottomButtons();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
....
classBB.bottomButtons();
Basically this is a LinearLayout View with buttons which I animate, I have no problem using this method directly inside an activity however I would like to call it (bottomButtons) from all my other activities as well instead of having the same block of code in all my activities.