Hi I am New To Android and I Want to Change the Textview Size and Textview Color of a Activity from Menu options I don't know how to Do it
I created a Menu item like this
<item android:id="@+id/menu_item_share"
android:title="Share"
android:showAsAction="ifRoom|withText"
android:orderInCategory="100"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
<item android:id="@+id/display"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="Display Option"
android:actionLayout="@layout/custom_setting" />
When I Click Display Option from the current layout Menu option a new layout want to be called.. in that layout I have created Two Button one is Plus Button and other one is Minus Button and I want these buttons to make changes to the previous layout.
When I Click the plus button the text view text want to be Change and when I click Minus Button the Text view Size was Reduced.
The Custom layout Code when Menu Item was Clicked
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.aeiltech.sidd.CustomSetting" android:background="@mipmap/bg">
<ImageButton
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/close"
android:layout_above="@+id/textView"
android:layout_toRightOf="@+id/minus"
android:layout_toEndOf="@+id/minus"
android:id="@+id/close" />
<ImageButton
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/plusign"
android:layout_marginTop="110dp"
android:id="@+id/plus"
android:layout_alignParentTop="true"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" />
<ImageButton
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/minusign"
android:id="@+id/minus"
android:layout_alignTop="@+id/plus"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Change Text Size"
android:id="@+id/textView"
android:layout_above="@+id/minus"
android:layout_centerHorizontal="true"
android:textColor="#FFFFFF" />
</RelativeLayout>
DetailActivity(This Activity have a Textview)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_activity);
detailtext= (TextView) findViewById(R.id.detail);
dbHelper = new SqlLiteDbHelper(this);
try {
dbHelper.openDataBase();
} catch (SQLException e) {
e.printStackTrace();
}
sqLiteDatabase = dbHelper.getReadableDatabase();
cursor=dbHelper.getdetails(sqLiteDatabase, selectedData);
if(cursor.moveToFirst())
{
detailtext.setText(cursor.getString(0));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_detail, menu);
MenuItem shareItem = menu.findItem(R.id.menu_item_share);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (id==R.id.display_option)
{
LayoutInflater layoutInflater= (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.custom_setting,null);
}
return super.onOptionsItemSelected(item);
}
To help clarify, this question is the same app and author as this App Crash When Trying to Change textsize in textView by clicking on button