ujjval rathod
Newbie
I have following .JAVA class for the activity and from this activity I want to start a next activity when a click on floating action button.
I am uploading the java nd xml code for the activity. Can anyone see any problem? Also, Do I need to add anything to the activity which starts from this activity?
I am uploading the java nd xml code for the activity. Can anyone see any problem? Also, Do I need to add anything to the activity which starts from this activity?
Java:
package com.example.ujjval.dateandtimepicker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.view.View;
/**
* Created by UJJVAL on 6/25/2017.
*/
public class secondactivity extends Activity{
@Override
// Method to link the JAVA class and Layout.
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.secondlayout );
}
// Method to call the main dateandtime activity
// FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.floatingActionButton3);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
public void nextAct(View v){
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
}
}
Code:
<?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">
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginBottom="26dp"
android:layout_marginEnd="22dp"
android:layout_marginRight="22dp"
android:clickable="true"
android:onClick="nextAct"
app:fabSize="mini"
app:srcCompat="@android:drawable/ic_input_add"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:background="@color/colorPrimaryDark"
android:layout_above="@+id/floatingActionButton3"
android:layout_alignLeft="@+id/floatingActionButton3"
android:layout_alignStart="@+id/floatingActionButton3"
android:layout_marginBottom="18dp"
android:id="@+id/searchView" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/searchView"
android:layout_toRightOf="@+id/searchView"
android:layout_gravity="bottom|right"
android:gravity="center"
android:layout_alignLeft="@+id/searchView"
android:layout_alignStart="@+id/searchView"
android:id="@+id/textInputLayout3">
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/searchView"
android:layout_alignLeft="@+id/searchView"
android:layout_alignStart="@+id/searchView"
android:layout_marginBottom="13dp"
android:background="@android:drawable/button_onoff_indicator_on"
app:srcCompat="@android:drawable/ic_menu_preferences" />
</RelativeLayout>