Hi, I'm trying to implement a BottonBar
, it's already in my xml file it shows perfectly in the activity the problem is. To add the functions android studio does not recognize me setOnNavigationItemSelectedListener
This is the code.
public class Centimeters extends AppCompatActivity {
private BottomNavigationItemView bottomNavigationView;
TextView text1 , text2 , text3 ;
EditText editText;
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_centimeters);
BottomNavigationItemView bottomNavigationItemView = (BottomNavigationItemView)findViewById(R.id.bottom_navigation);
bottomNavigationItemView.setOnNavigationItemSelectedListener (new BottomNavigationItemView())
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getSupportActionBar().hide();
text1 = (TextView)findViewById(R.id.tex1centimeters);
text2 = (TextView)findViewById(R.id.tex2centimeters);
text3 = (TextView)findViewById(R.id.tex1centimeters);
final DecimalFormat decimales = new DecimalFormat("0.00"); /** la cantidad de digitos decimales que se muestra */
final EditText editText = (EditText)findViewById(R.id.editcentimeters);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (!(editText.getText().toString()).isEmpty()){
double valor = Double.parseDouble(editText.getText().toString());
if (valor >= 0 ){
double resu1 = valor / 3.48; /**centimeters to feet formula */
text1.setText(decimales.format(resu1));
double resu2= valor / 2.54 ;/**centimeters to inches formula */
text2.setText(decimales.format(resu2));
double resu3 = valor*10;/**centimeter to mm formula*/
text3.setText(decimales.format(resu3));
}
else {
text1.setText("");
text2.setText("");
text3.setText("");
}
}
}
});
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.liantonypozo.calculosmatematicos3"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:support-v4:25.3.0'
testCompile 'junit:junit:4.12'
}