Issue
I have a button in Android Studio:
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Event Name (23)" />
It looks like this:
-------------------------------------
| Event Name (23) |
-------------------------------------
What I would like is two pieces of text in a single button.
Basically, I want on the left side of the button, the name of an event... then I want on the right side of the button to have the number of people registered for the event, so it looks like this:
-------------------------------------
| Event Name (23) |
-------------------------------------
Is something like this possible?
I am completely new to Android, so keep that in mind.
Solution
You can create Layout instead of Button and Then perform click event on layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:id="@+id/relLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Event Name"
android:layout_alignParentLeft="true"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="(23)"
android:textSize="16sp"/>
</RelativeLayout>
In Activity :
RelativeLayout relLayout = (RelativeLayout) findViewById(R.id.relLayout);
relLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Implement Your login on RelativeLayout click
}
});
Answered By - Bhargav Thanki
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.