SqliteBrowser PPA
sudo add-apt-repository ppa:linuxgndu/sqlitebrowser sudo apt-get update
References
https://github.com/sqlitebrowser/sqlitebrowser
https://launchpad.net/~linuxgndu/+archive/ubuntu/sqlitebrowser
sudo add-apt-repository ppa:linuxgndu/sqlitebrowser sudo apt-get update
References
https://github.com/sqlitebrowser/sqlitebrowser
https://launchpad.net/~linuxgndu/+archive/ubuntu/sqlitebrowser
/res/drawable/gradient_color.xml
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:angle="135" android:startColor="@color/colorBackground" android:endColor="@color/colorPrimary" android:type="linear" /> <corners android:radius="0dp"/> </shape>
activity_main.xml
<FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/editTextWeight" android:background="@drawable/gradient_color"> <Button android:id="@+id/buttonStart" android:background="?android:attr/selectableItemBackground" android:textAllCaps="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/start" /> </FrameLayout>
References
https://github.com/mhdr/AndroidSamples/tree/master/077
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextGoesHere" style="?android:attr/borderlessButtonStyle" />
References
https://github.com/mhdr/AndroidSamples/tree/master/076
activity_main.xml
<TextView android:id="@+id/textViewProfileName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_below="@+id/textViewFirstRunHeader2" android:focusable="true" android:focusableInTouchMode="true" android:gravity="center|start" android:text="@string/profile_name" android:textColor="@android:color/black" android:textSize="16sp" android:textStyle="bold" />
MainActivity.java
textViewProfileName= (TextView) findViewById(R.id.textViewProfileName); textViewProfileName.requestFocusFromTouch();
References
https://github.com/mhdr/AndroidSamples/tree/master/075
<Button android:id="@+id/buttonSaveHeight" android:layout_marginTop="20dp" android:layout_marginBottom="10dp" android:text="@string/ok" android:gravity="center" android:layout_gravity="center" android:background="@android:color/transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" />
References
https://github.com/mhdr/AndroidSamples/tree/master/074
build.gradle
dependencies { compile 'uk.co.chrisjenx:calligraphy:2.2.0' }
Add Application Class :
MyApplication.java
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/BYekan.ttf") .setFontAttrId(R.attr.fontPath) .build()); } }
Register your Application Class :
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ir.mhdr.a072"> <application android:allowBackup="true" android:name=".MyApplication" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Add attachBaseContext to all Activities
MainActivity.java
public class MainActivity extends AppCompatActivity { NumberPicker numberPicker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); numberPicker= (NumberPicker) findViewById(R.id.numberPicker); numberPicker.setMinValue(0); numberPicker.setMaxValue(99); numberPicker.setValue(24); } @Override protected void attachBaseContext(Context base) { super.attachBaseContext(CalligraphyContextWrapper.wrap(base)); } }
References
https://github.com/mhdr/AndroidSamples/tree/master/073
https://github.com/chrisjenx/Calligraphy
https://blog.goyello.com/2014/08/01/how-to-use-custom-fonts-in-android-apps-and-not-get-fat-3/
ExampleDialogFragment.java
@Override public void onResume() { super.onResume(); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.WRAP_CONTENT); }
References
https://github.com/mhdr/AndroidSamples/tree/master/072
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.mhdr.a071.MainActivity"> <TextView android:id="@+id/textViewMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World 12!" android:layout_below="@+id/numberPicker" android:layout_centerHorizontal="true" android:layout_marginTop="115dp" /> <ir.mhdr.a071.CustomNumberPicker android:id="@+id/numberPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:gravity="center" /> </RelativeLayout>
CustomNumberPicker.java
public class CustomNumberPicker extends NumberPicker { public CustomNumberPicker(Context context) { super(context); } public CustomNumberPicker(Context context, AttributeSet attrs) { super(context, attrs); } public CustomNumberPicker(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public void addView(View child) { super.addView(child); updateView(child); } @Override public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) { super.addView(child, index, params); updateView(child); } @Override public void addView(View child, android.view.ViewGroup.LayoutParams params) { super.addView(child, params); updateView(child); } private void updateView(View view) { Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/BNazanin.ttf"); if(view instanceof EditText) { ((EditText) view).setTypeface(typeface); } if (view instanceof TextView) { ((TextView) view).setTypeface(typeface); } } }
MainActivity.java
public class MainActivity extends AppCompatActivity { TextView textViewMessage; CustomNumberPicker numberPicker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textViewMessage = (TextView) findViewById(R.id.textViewMessage); // the base way to do this in android // the font is placed on assets/fonts/BNazanin.ttf Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/BNazanin.ttf"); textViewMessage.setTypeface(typeface); // for other views we need to extend view numberPicker = (CustomNumberPicker) findViewById(R.id.numberPicker); numberPicker.setMinValue(0); numberPicker.setMaxValue(99); numberPicker.setValue(34); } }
References
https://github.com/mhdr/AndroidSamples/tree/master/071
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.mhdr.a070.MainActivity"> <NumberPicker android:id="@+id/numberPicker2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="166dp" /> </RelativeLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity { NumberPicker numberPicker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); numberPicker= (NumberPicker) findViewById(R.id.numberPicker2); numberPicker.setMaxValue(99); numberPicker.setMinValue(0); numberPicker.setValue(25); numberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); } }
References
https://github.com/mhdr/AndroidSamples/tree/master/070
let oldItem: any = ViewModels.adminUsers.users()[index]; let newItem: any = {...oldItem}; // shallowcopy