what's the PROB?PLZ help

+1 ahmed khelili · February 8, 2016

package com.example.pcc.m4;

import android.os.Bundle;


import android.support.v7.app.AppCompatActivity;

import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Button;
import android.transition.TransitionManager;

public class MainActivity extends AppCompatActivity {
ViewGroup ahmedLayout;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ahmedLayout =(ViewGroup)findViewById(R.id.ahmedLayout);
ahmedLayout.setOnTouchListener(
new RelativeLayout.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
moveButton();
return true;

}

}
);
public void moveButton(){
TransitionManager.beginDelayedTransition(ahmedLayout);

View ahmedButton = findViewById(R.id.ahmedButton);
RelativeLayout.LayoutParams positionRules = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
positionRules.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
positionRules.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,RelativeLayout.TRUE);
ahmedButton.setLayoutParams(positionRules);
ViewGroup.LayoutParams sizeRules= ahmedButton.getLayoutParams();
sizeRules.width=300;
sizeRules.height=450;

ahmedButton.setLayoutParams(sizeRules);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.

return false;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement


return super.onOptionsItemSelected(item);
}
}?

Post a Reply

Replies

Oldest  Newest  Rating
0 Gary Whitney · February 9, 2016
While your code is small and someone might be able to spot the problem.

It is better to post the Stack Trace.
It is best to learn to understand the Stack Trace.

1. The top of the trace is where the error occurs.
2. Somewhere below you will see a call by YOUR code.
It will even tell you the line on which the error occurred.
  • 1

Java / Android Development

107,060 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator