Saturday, 21 January 2017

android - Layout Inflate Error Fragment

MainActivity:




    public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);



FloatingActionButton fab2 = (FloatingActionButton) findViewById(R.id.developer);
fab2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CFAlertDialog.Builder builder = new CFAlertDialog.Builder( MainActivity.this)
.setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT)
.setTitle("Developer Info")
.setMessage ( "This Application is Developed By :\nPriyansh MIshra\nB.Tech CSE \nAUMP Gwalior" )

.addButton( "OK", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE,
CFAlertDialog.CFAlertActionAlignment.CENTER, ( dialog, which) -> {
dialog.dismiss();
});

builder.show();

}
});




FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.info);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CFAlertDialog.Builder builder = new CFAlertDialog.Builder( MainActivity.this)
.setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT)
.setTitle("Info\n"+"App v1.0\n")
.setMessage ( "Amity YouthFest \nPresents Chroma 2K18" )

.addButton( "OK", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE,
CFAlertDialog.CFAlertActionAlignment.CENTER, ( dialog, which) -> {
dialog.dismiss();
});

builder.show();

}
});


FloatingActionButton fab1 = (FloatingActionButton) findViewById(R.id.contactus);
fab1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendEmail();
}
});

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(

this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
displaySelectedScreen(R.id.nav_home);
}

private void sendEmail ( ) {


String[] TO = {""};
String[] CC = {""};
Intent emailIntent = new Intent(Intent.ACTION_SEND);

emailIntent.setData( Uri.parse( "mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"priyansh.mishra19@gmail.com"});
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Groomauto:Enquiry");

emailIntent.putExtra(Intent.EXTRA_TEXT, " ");

try {
startActivity(Intent.createChooser(emailIntent,"Send mail..."));
finish();

} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText( MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}

@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
public boolean onNavigationItemSelected(MenuItem item) {

displaySelectedScreen(item.getItemId());
return true;
}
private void displaySelectedScreen(int itemId) {

//creating fragment object
Fragment fragment = null;


switch (itemId) {

case R.id.nav_home:
fragment = new FragmentHome ();
break;
case R.id.nav_about:
fragment = new FragmentAbout ();
break;

case R.id.nav_events:
fragment = new FragmentEvents ();
break;


case R.id.nav_gallery:
fragment = new FragmentGallery ();
break;

case R.id.nav_winners:
fragment = new FragmentWinners();
break;

case R.id.nav_login:

fragment = new FragmentRegister();
break;





}
//replacing the fragment
if (fragment != null) {

FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(content_frame, fragment);
ft.commit();
}

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}



}



XML Code :



android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent">


android:layout_width="match_parent"
android:background="@drawable/fundo"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">

android:layout_width="match_parent"

android:id="@+id/fadingTextView1"
android:layout_height="wrap_content">


android:layout_width="match_parent"
android:layout_height="100dp"
app:texts="@array/examples"
app:timeout="500"
android:padding="10dp"
android:textSize="18sp"
android:fontFamily="casual"
android:textStyle="bold"

android:textAlignment="center"
android:textColor="@color/colorAccent"
android:id="@+id/fadingTextView"/>



android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout1"

android:layout_below="@id/fadingTextView1"
android:layout_margin="0dp">

android:id="@+id/slider"
android:layout_width="fill_parent"
android:layout_height="320dp"
/>




android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:id="@+id/title"
android:textStyle="bold"
android:textAlignment="center"
android:layout_below="@id/layout1"
android:text="Reviews and Words Of Wisdom"

android:textColor="@color/colorAccent"/>

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_below="@id/title"
>


android:layout_width="match_parent"
android:scrollbars="horizontal"
android:layout_height="wrap_content">

android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">




android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content">




android:layout_width="280dp"
app:cardCornerRadius="20dp"
android:layout_margin="10dp"
android:layout_height="300dp"
>

android:orientation="vertical"
android:layout_width="match_parent"
android:paddingTop="10dp"

android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/vc"
app:civ_border_color="#e6e1e1"
app:civ_border_width="6dp"
android:layout_marginLeft="40dp"
android:layout_gravity="center_horizontal"
app:civ_shadow="true"

app:civ_shadow_radius="20"
app:civ_shadow_color="#8BC34A"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#1d3bd2"
android:textSize="20sp"
android:textStyle="normal" />

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Passion and commitment to make our university on top is visible among students, dosed with sense of responsibility within."
android:textAlignment="center"
android:textColor="#000"
android:textSize="15sp"
android:textStyle="normal" />






android:layout_width="280dp"
app:cardCornerRadius="20dp"
android:layout_margin="10dp"
android:layout_height="300dp"
>


android:orientation="vertical"
android:layout_width="match_parent"
android:paddingTop="10dp"

android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/provc"
app:civ_border_color="#e6e1e1"

app:civ_border_width="6dp"
android:layout_marginLeft="40dp"
android:layout_gravity="center_horizontal"
app:civ_shadow="true"
app:civ_shadow_radius="20"
app:civ_shadow_color="#8BC34A"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"

android:textColor="#1d3bd2"
android:textSize="20sp"
android:textStyle="normal" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Kudos to all the wonderful efforts the students are putting into developing young talent for this great university."
android:textAlignment="center"
android:textColor="#000"
android:textSize="15sp"

android:textStyle="normal" />




android:layout_width="280dp"
app:cardCornerRadius="20dp"
android:layout_margin="10dp"
android:layout_height="300dp"

>

android:orientation="vertical"
android:layout_width="match_parent"
android:paddingTop="10dp"

android:layout_height="wrap_content">
android:layout_width="match_parent"

android:layout_height="150dp"
android:src="@drawable/hoi"
app:civ_border_color="#e6e1e1"
app:civ_border_width="6dp"
android:layout_marginLeft="40dp"
android:layout_gravity="center_horizontal"
app:civ_shadow="true"
app:civ_shadow_radius="20"
app:civ_shadow_color="#8BC34A"/>

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#1d3bd2"
android:textSize="20sp"
android:textStyle="normal" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Wonderful organization of symposium by our students. I wish them all the best for their future endeavours."

android:textAlignment="center"
android:textColor="#000"
android:textSize="15sp"
android:textStyle="normal" />




android:layout_width="280dp"

app:cardCornerRadius="20dp"
android:layout_margin="10dp"
android:layout_height="300dp"
>

android:orientation="vertical"
android:layout_width="match_parent"
android:paddingTop="10dp"


android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/nasirkhan"
app:civ_border_color="#e6e1e1"
app:civ_border_width="6dp"
android:layout_marginLeft="40dp"
android:layout_gravity="center_horizontal"
app:civ_shadow="true"

app:civ_shadow_radius="20"
app:civ_shadow_color="#8BC34A"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#1d3bd2"
android:textSize="20sp"
android:textStyle="normal" />

android:layout_width="match_parent"
android:layout_height="wrap_content"

android:textAlignment="center"
android:textColor="#000"
android:textSize="15sp"
android:textStyle="normal" />
















Fragment Class



 @SuppressLint("ValidFragment")
public class FragmentHome extends android.support.v4.app.Fragment implements BaseSliderView.OnSliderClickListener, ViewPagerEx.OnPageChangeListener{

SliderLayout sliderLayout;
HashMap Hash_file_maps ;



@Nullable
@Override
public View onCreateView (@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) {
return inflater.inflate( R.layout.fragment_home, container, false);
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);


String[] texts = {"YouthFest Of The Year \n We Hold A Brand \n Let's Make A Dream Come True ",
"Most Awaited YouthFest Chroma \n AUMP" ,
" Grab The Opputunity \n Light Your Night \n DJ NIght"};
FadingTextView FTV = (FadingTextView)view.findViewById( R.id.fadingTextView);
FTV.setTexts(texts);

Hash_file_maps = new HashMap();

sliderLayout = (SliderLayout)view.findViewById(R.id.slider);


Hash_file_maps.put("Android Workshop", "http://www.i3indyatechnologies.com/img/android-application-development.jpg");
Hash_file_maps.put("Ludo", "http://amityaump.com/android%20images/ludo.jpg");
Hash_file_maps.put("Python Workshop", "https://aeccodingclub.files.wordpress.com/2017/01/python-workshop-poster-viveks.jpg?w=1024");
Hash_file_maps.put("Treasure Hunt", "http://amityaump.com/android%20images/treasure%20hunt.jpg");
Hash_file_maps.put("Solo Dance", "http://amityaump.com/android%20images/solo%20dance.jpg");

for(String name : Hash_file_maps.keySet()){

TextSliderView textSliderView = new TextSliderView(FragmentHome.this.getActivity());
textSliderView

.description(name)
.image(Hash_file_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
textSliderView.bundle(new Bundle());
textSliderView.getBundle()
.putString("extra",name);
sliderLayout.addSlider(textSliderView);
}
sliderLayout.setPresetTransformer(SliderLayout.Transformer.Accordion);

sliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
sliderLayout.setCustomAnimation(new DescriptionAnimation());
sliderLayout.setDuration(3000);
sliderLayout.addOnPageChangeListener(this);

}
@Override
public void onStop() {

sliderLayout.stopAutoCycle();


super.onStop();
}

@Override
public void onSliderClick(BaseSliderView slider) {

}

@Override

public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}

@Override
public void onPageSelected(int position) {

Log.d("Slider Demo", "Page Changed: " + position);
}

@Override
public void onPageScrollStateChanged(int state) {}

}



Error : java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.darkweb.android.chroma2018/com.darkweb.android.chroma2018.MainActivity}:
android.view.InflateException: Binary XML file line #0: Error
inflating class
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)

at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)

at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0:
Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)

at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at
com.darkweb.android.chroma2018.FragmentHome.onCreateView(FragmentHome.java:36)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...