Skip to content

Instantly share code, notes, and snippets.

@amiraelsayedbadwy
Created April 8, 2016 16:43
Show Gist options
  • Save amiraelsayedbadwy/0d9120f27c8451cbdd5767092a0af3ad to your computer and use it in GitHub Desktop.
Save amiraelsayedbadwy/0d9120f27c8451cbdd5767092a0af3ad to your computer and use it in GitHub Desktop.
details
package com.example.amira.movies;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class Details extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new Fetchdata())
.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_details, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
// class fragment
public static class Fetchdata extends android.support.v4.app.Fragment {
public Fetchdata() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_details, container, false);
Intent intent = getActivity().getIntent();
if (intent != null && intent.hasExtra(Intent.EXTRA_TEXT)) {
String overview = intent.getStringExtra("over");
((TextView) rootView.findViewById(R.id.over))
.setText(overview);
String releasedate = intent.getStringExtra("date");
((TextView) rootView.findViewById(R.id.rre))
.setText(releasedate);
}
return rootView;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment