<LinearLayout 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="com.example.android.MainActivity"
android:id="@+id/action_container">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:onClick="onMyButtonClick"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="153dp"
android:layout_marginLeft="148dp"
app:layout_constraintLeft_toLeftOf="parent" />
</LinearLayout>
import android.app.FragmentTransaction;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onMyButtonClick(View view) {
Toast.makeText(this, "Зачем вы нажали?", Toast.LENGTH_SHORT).show();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.action_container, new BlankFragment());
}
}
int pos = Arrays.binarySearch(wordArr, prefixItem ); // if positive, point to a word in vocabulary started from prefix or equal to it
if ( pos < 0) // no precise prefix value found in vocabulary
{
pos = -(pos + 1); // pos to the first element starting from prefix
}