I have this xml-Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:background="#color/white" android:layout_width="fill_parent" android:layout_height="200px">
<TextView
android:layout_x="0dp"
android:layout_y="10dp"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:textColor="#color/white"
android:text="Name: " />
<EditText
android:layout_x = "20px"
android:layout_y = "10px"
android:layout_gravity="left"
android:textSize="15sp"
android:id="#+id/et_username" android:textColor="#color/black"
android:layout_width="150px"
android:layout_height="50px" />
<Button
android:layout_x = "200px"
android:layout_y = "10px"
android:layout_gravity="left"
android:textSize="16sp"
android:layout_width="96px"
android:layout_height="50px"
android:background ="#drawable/login"
android:id="#+id/btn_login"
android:textColor="#color/white"
android:text="next"
android:onClick="onLoginClicked" />
</AbsoluteLayout>
</LinearLayout>
java File :
public class ButtonAdapter extends BaseAdapter {
...
public View getView(int position, View convertView, ViewGroup parent) {
return LayoutInflater.from(mContext).inflate(R.layout.custom_keyboard, null);
}
public void onLoginClicked(View v) {
Button button = (Button) v;
String key = button.getText().toString();
anotherMethod(key, false);
}
...
}
and I use the adapter here:
GridView gridview = new GridView(context);
gridview2.setAdapter(new KeyboardAdapter(1, context));
can anybody tell me, why do I get the following error when I click the button?
java.lang.IllegalStateException: Could not find a method onLoginClicked(View) in the activity class MainActivity for onClick handler on view class android.widget.Button
This happening because you have the following in your xml:
<Button
android:layout_x = "200px"
android:layout_y = "10px"
android:layout_gravity="left"
android:textSize="16sp"
android:layout_width="96px"
android:layout_height="50px"
android:background ="#drawable/login"
android:id="#+id/btn_login"
android:textColor="#color/white"
android:text="next"
android:onClick="onLoginClicked" />
The last line means that when this button is clicked, a method will be invoked. This method is named "onLoginClicked", it should be public and have a parameter of type View and be defined in the Activity class.
So, go to your activity and write something like:
public void onLoginClicked(View v) {
//toast, log, open activity, etc
}
Why are you trying to make the code more complex.
Just try to do this :
Button b=(Button)findViewId(R.id.btn_login);
b.setOnClickListener(new OnClickListener(){
//perform your action here
});
I would remove the onClick parameter from your layout XML and handle the click with a listener. Add this code to your onCreate() method in your activity:
Button button = (Button)findViewById(R.id.btn_login);
button.setOnClickListener(new OnClickListener(){
String key = button.getText().toString();
anotherMethod(key, false);
});
Related
In my Fragment, I have three controls: two ImageViews and a Button:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:id="#+id/rel_layout"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#ffffffff"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="#+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:textStyle="bold"
android:visibility="visible"
android:textSize="25sp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp" />
<ImageView
android:id="#+id/forward"
android:background="#drawable/chevronright"
android:layout_below="#+id/heading"
android:layout_alignParentEnd="true"
android:layout_width="50dp"
android:layout_height="50dp" />
<ImageView
android:id="#+id/back"
android:background="#drawable/chevronleft"
android:layout_below="#+id/heading"
android:visibility="invisible"
android:layout_alignParentStart="true"
android:layout_width="50dp"
android:layout_height="50dp" />
<Button
android:id="#+id/skip_button"
android:text="#string/skip_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_below="#+id/back"
android:layout_alignParentStart="true"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentStart="true"
android:layout_below="#+id/heading" >
<TextView
android:id="#+id/body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="normal"
android:visibility="visible"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
In the fragment, I define onClickListeners for all three controls:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
SharedPreferences sharedPref = getActivity().getSharedPreferences("WDWHIC settings", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("lastPage", INTRO);
editor.commit();
View view = inflater.inflate(R.layout.fragment_intro, container, false);
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(R.string.intro_page_full);
RelativeLayout topLayout = getActivity().findViewById(R.id.topLayout);
topLayout.setVisibility(View.INVISIBLE);
final Animation in = new AlphaAnimation(0.0f, 1.0f);
in.setDuration(500);
RelativeLayout rel_layout = view.findViewById(R.id.rel_layout);
Resources res = getResources();
pages = res.getStringArray(R.array.pages_array);
heading = rel_layout.findViewById(R.id.heading);
heading.setText(pages[pageNum]);
forward = rel_layout.findViewById(R.id.forward);
forward.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
back.setVisibility(View.VISIBLE);
pageNum += 2;
heading.setText(pages[pageNum]);
body.startAnimation(in);
body.setText(pages[pageNum + 1]);
body.scrollTo(0, 0);
if (pageNum == 2 * MAX_PAGES) forward.setVisibility(View.INVISIBLE);
}
});
back = rel_layout.findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
forward.setVisibility(View.VISIBLE);
pageNum -= 2;
heading.setText(pages[pageNum]);
body.startAnimation(in);
body.setText(pages[pageNum + 1]);
body.scrollTo(0, 0);
if (pageNum == 0) back.setVisibility(View.INVISIBLE);
}
});
skip = rel_layout.findViewById(R.id.skip_button);
skip.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
EditProfileFragment editProfileFragment = new EditProfileFragment();
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.beginTransaction().replace(R.id.fragment_container, editProfileFragment, editProfileFragment.getTag()).commit();
getActivity().overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
body = rel_layout.findViewById(R.id.body);
body.startAnimation(in);
body.setText(pages[pageNum + 1]);
body.setMovementMethod(new ScrollingMovementMethod());
return view;
}
If I click on the 'skip' button while on the first page, its onClick() method gets called. But if I click on forward or back, it doesn't unless I return to the first page. What's up with this? Why should advancing pages make a difference?
Try adding android:clickable="true" to your image views.
In the documentation:
android:clickable Defines whether this view reacts to click events.
https://developer.android.com/reference/android/view/View#attr_android:clickable
Therefore, in theory, the View's onClickListener won't be fire if clickable is not set to true.
I would try setting the onClickListener functionality in the class that extends FragmentActivity.
In the class that implements your onCreateView method define a static handler and initialized it with the static handler that should be defined in the class that extends FragmentActivity.
from the class that implements onCreateView create an android message to send to the static handler of your class that extends FragmentActivity. In this message send an object which is your button that will implement the onClickListener. Note: Create and send this message from inside your onCreateView.
Once the message is received inside the class that extends FragmentActivity, send the
object that arrives in the message( which is a view that is actually your button) as a parameter to a private method that resides inside your class that extends FragmentActivity.
Inside this private method try to set the onClickListener functionality.
I don't know why this should work, but I moved the button above the heading, without changing anything else, and now onClick() gets called from every page.
<Button
android:id="#+id/skip_button"
android:text="#string/skip_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_alignParentEnd="true"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/skip_button"
android:textStyle="bold"
android:visibility="visible"
android:textSize="25sp"
android:layout_marginStart="10dp" />
I want to add filter button to my onCreateOptionsMenu. When button was clicked i need to show layout with checkboxes and apply button.
Only way that i know how to do this - start new activity from onOptionsItemSelected and do all operations there. But is there more efficient way? Without leaving current activity. Something like pop-up window etc.
You can do it By Using this Material Dialog
https://github.com/drakeet/MaterialDialog Library and Below code, Just
put the gravity of Dialog TOP|RIGHT.
private void showMaterialDialog() {
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice);
for (Card card : cards) {
arrayAdapter.add(card.getName());
}
alert = new MaterialDialog(this);
View mView = getLayoutInflater().inflate(R.layout.custom_view_virtual_card, null);
ListView listView = (ListView) mView.findViewById(R.id.listView);
listView.setAdapter(arrayAdapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
AppCompatButton btnCancel = (AppCompatButton) mView.findViewById(R.id.btnCancel);
AppCompatButton btnOk = (AppCompatButton) mView.findViewById(R.id.btnOk);
btnOk.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startAsyncForRequestVirtualCard(selectedCardTypeId);
alert.dismiss();
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
alert.dismiss();
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedCardTypeId = cards.get(position).getId();
Log.d("request", cards.get(position).getId() + " " + cards.get(position).getName());
}
});
alert.setView(mView);
alert.show();
}
custom_view_virtual.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Select Card Type"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorAccent" />
<View
android:layout_width="match_parent"
android:layout_height="0.25dp"
android:background="#color/divider" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:divider="#color/transparent"
android:theme="#style/ProgressBarStyle"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp">
<android.support.v7.widget.AppCompatButton
android:id="#+id/btnCancel"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="#string/cancel"
android:textColor="#color/colorAccent"
android:textSize="15sp" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btnOk"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ok"
android:textColor="#color/colorAccent"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
Don't create a new activity instead create a new java class in that apply your sorting logic to filter the content and when your button is pressed that activity should return all your sorted content using List class or ArrayList class or anything else then display it.
I'am trying to click a button on my list view to update that row first of all I tried to click on the item in the list view to show toast.
I did setOnItemClickListener of the ListView
public class Medlistview extends Activity{
DB db = new DB(this);
ImageButton updateimagebutton = (ImageButton)findViewById(R.id.editbuttonimage);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.medlistview);
populatemedlistview();
}
public void populatemedlistview(){
Cursor cursor = db.getMEDINF();
String[] medinfo = new String[]{
DB.col1,DB.col2,DB.col3,DB.col4,DB.rowID
};
int[] mappingmed = new int[]{
R.id.MEDid,R.id.MedName,R.id.Medpurpose,R.id.medNotaplet,R.id.ROWID
};
SimpleCursorAdapter medcursoradapter = new SimpleCursorAdapter(this,R.layout.medlistviewxml,cursor,medinfo,mappingmed);
ListView medlistview = (ListView)findViewById(R.id.listViewmed);
medlistview.setAdapter(medcursoradapter);
medlistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(Medlistview.this,"clicked",Toast.LENGTH_LONG).show();
}
});
}
}
I made sure that my list view is clickable and focusable but still not working
One more thing I already define image button on layout item not on ListVew layout every time I run the app, is crashing and showing that null reference message in the log-cat do I need to define the button also on the ListView layout.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.findViewById(int)' on a null object reference
My xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ListView
android:layout_width="match_parent"
android:layout_height="282dp"
android:id="#+id/listViewmed"
android:layout_weight="0.40"
android:background="#c7c0c0"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
Here is my list item xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/MEDid"
android:layout_marginTop="40dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/MedName"
android:layout_below="#+id/MEDid"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/Medpurpose"
android:layout_below="#+id/MedName"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/medNotaplet"
android:layout_below="#+id/Medpurpose"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editbuttonimage"
android:layout_above="#+id/Medpurpose"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/editicon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/ROWID"
android:layout_alignBottom="#+id/medNotaplet"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Thanks in Advance.
Implement View.OnClickListener() to your ImageButton in getView() method in your adapter, not in Medlistview activity. And use callback or eventBus to work with click action in your activity.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.recycler_view_item, parent, false);
holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tvName.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Button was clicked
}
});
return convertView;
}
Set
android:focusable="false"
android:focusableInTouchMode="false"
for all UIs controls in your custom layout file.
use android:descendantFocusability="blocksDescendants" inside listview,
check out this answere: can't click on listview row with imagebutton
Set the parent layout of the item
android:descendantFocusability="blocksDescendants"
and set
android:clickable="false"
android:focusable="false">
on all your widgets.
UPDATE
My button is as big as the view of each ListItem - maybe this causes the problem? Is it possible to press once and let both OnItemclick and OnClick respond?
I have a list view with two textviews and a button. I know there are a lot of questions being posted but I have read a lot of them and not one seems to work.
I want the OnItemClick of each view of the list view to work.
I also want the OnClick of the button inside each view of the list view to work.
Only the onClick of the button seems to respond
In my xml i have set android:focusable="false" for the button. For the textviews I have set android:textIsSelectable="false" android:clickable="false" android:focusable="false"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rectangle_order"
android:layout_gravity="center_horizontal"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="#dimen/order_height"
>
<Button
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
/>
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textStyle="bold"
android:textSize="#dimen/text_size"
android:textColor="#color/white"
android:rotation="90"
android:textIsSelectable="false"
android:clickable="false"
android:focusable="false"
/>
<TextView
android:id="#+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="#dimen/timer_size"
android:rotation="90"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="29dp"
android:textIsSelectable="false"
android:clickable="false"
android:focusable="false"
/>
</RelativeLayout>
</RelativeLayout>
this is the layout for my list view:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="0.5"
android:layout_width="#dimen/order_height"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
>
<ListView
android:id="#+id/list"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="0.5"
android:divider="#android:color/transparent"
android:dividerHeight="10.0sp"
android:scrollbars="none"
>
</ListView>
</RelativeLayout>
In the GetView of my adapter i have :
Button b = (Button) rowView.findViewById(R.id.img);
b.setBackgroundResource(R.color.pending);
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if(numberOfTimers < 2){
view.setBackgroundResource(R.color.ongoing);
countDownTimer = new MyCountDownTimer(TIME_PANINI, 1000,timerTextView, view);
countDownTimer.start();
}
}
});
in my main activity i have a onItemClickListener set to the listView:
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.d(TAG_MAIN, "we are in select onitemclicklistener");
Toast.makeText(getApplicationContext(),"BOOOOH", Toast.LENGTH_SHORT).show();
}
});
Try to replace OnClickListener with OnTouchListener.
Like this:
b.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction()==MotionEvent.ACTION_DOWN){
if(numberOfTimers < 2){
view.setBackgroundResource(R.color.ongoing);
countDownTimer = new MyCountDownTimer(TIME_PANINI, 1000,timerTextView, view);
countDownTimer.start();
}
}
return false;
}
};);
When you return false at this listener, you mean "hey i'm not done with that action(press down), please let the action to the next View"
I have an app, which shows toast below the actionbar. I'm using Crouton library for displaying toast. Here I'm placing custom layout for toast, that layout contains one textview and one button (for close option). So Toast appears with button. If I click that it should close the toast but nothing happens.. Below Code for this example. Any Help Appreciated
MainActivity.java
public class MainActivity extends SherlockActivity implements OnClickListener {
private View customToastView;
private TextView customToastMessageView;
private Button customToastCloseButton;
private Button doneButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
doneButton = (Button) findViewById(R.id.done_button);
customToastView = getLayoutInflater().inflate(R.layout.toast_custom_layout, null);
customToastMessageView = (TextView) customToastView.findViewById(R.id.messages);
customToastCloseButton = (Button) customToastView.findViewById(R.id.close_button);
customToastCloseButton.setOnClickListener(this);
doneButton.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.done_button:
Crouton.cancelAllCroutons();
customToastMessageView.setText("Message");
Crouton.show(this, customToastView);
break;
case R.id.close_button:
Crouton.cancelAllCroutons();
break;
}
}
}
toast_custom_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/messages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="26dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="23dp"
android:text="Button" />
</RelativeLayout>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/done_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="146dp"
android:text="Button" />
</RelativeLayout>