У меня приложение настроено, поэтому, когда я нажимаю на представление об переработке, правильно просмотреть переходы изображений фильма на активность B. Теперь, когда я пытаюсь заполнить информацию об объекте в активности B (например, сюжет и т. Д.) Я получаю Ошибка говорит, что то, что у меня есть в Bindviewholder, является нулевым. Я, должно быть, что -то упускаю, потому что то, как у меня было приложение, настраивалось раньше (вся информация на одной карте) все было запрашивалось правильно и отображалось. Все начало происходить, когда я решил изменить и отправить информацию в действие b. < /P>
Вот адаптер < /p>
public class MoviesAdapter extends RecyclerView.Adapter {
private List moviesList;
private Context context;
private ClickListener clickListener;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public MoviesAdapter(Context context, List moviesList) {
this.moviesList = moviesList;
this.context = context;
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView title, plot, releaseDate, rating;
public ImageView thumb;
public NetworkImageView moviePic;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
title = (TextView) view.findViewById(R.id.name);
plot = (TextView) view.findViewById(R.id.plot);
releaseDate = (TextView) view.findViewById(R.id.releaseDate);
rating = (TextView) view.findViewById(R.id.rating);
thumb = (ImageView) view.findViewById(R.id.thumb);
moviePic = (NetworkImageView) view.findViewById(R.id.profilePic);
}
@Override
public void onClick(View v) {
//context.startActivity(new Intent(context,DisplayActivity.class));
if (clickListener != null) {
clickListener.itemClicked(v, getAdapterPosition());
}
}
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.movie_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
MovieData movie = moviesList.get(position);
holder.title.setText(movie.getTitle());
holder.plot.setText(movie.getPlot());
holder.releaseDate.setText(movie.getReleaseDate());
holder.rating.setText(movie.getRating());
Float nRating = Float.parseFloat(holder.rating.getText().toString());
if (nRating > 6.5) {
holder.thumb.setImageResource(R.drawable.ic_thumbs_up);
} else {
holder.thumb.setImageResource(R.drawable.ic_thumbdown);
}
holder.moviePic.setImageUrl(movie.getImage(), imageLoader);
}
@Override
public int getItemCount() {
return moviesList.size();
}
//Interface and method to help with clicks
public interface ClickListener {
void itemClicked(View view, int position);
}
public void setClickListener(ClickListener clickListener) {
this.clickListener = clickListener;
}
< /code>
Вот MainActivity < /p>
public class MainActivity extends AppCompatActivity implements MoviesAdapter.ClickListener {
private static final String TAG = MainActivity.class.getSimpleName();
static final int SETTINGS_INTENT_REPLY = 1;
private MoviesAdapter mAdapter;
private List mData = new ArrayList();
private RecyclerView recyclerView;
private GridLayoutManager gridLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//check Sdk Level
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mAdapter = new MoviesAdapter(this, mData);
mAdapter.setClickListener(this);
gridLayoutManager = new GridLayoutManager(this,2);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
refreshMovie();
}
@Override
public void onActivityResult(int settingsRequestCode, int settingsResultcode, Intent resultData) {
super.onActivityResult(settingsRequestCode, settingsResultcode, resultData);
if (settingsRequestCode == SETTINGS_INTENT_REPLY) {
refreshMovie();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, 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();
if (id == R.id.action_settings) {
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, SETTINGS_INTENT_REPLY);
return true;
}
return super.onOptionsItemSelected(item);
}
public void refreshMovie() {
// Get a reference to the ConnectivityManager to check state of network connectivity
ConnectivityManager connMgr = (ConnectivityManager)
this.getSystemService(Context.CONNECTIVITY_SERVICE);
// Get details on the currently active default data network
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
// If there is a network connection, fetch data
if (networkInfo != null && networkInfo.isConnected()) {
mData.clear();
networkCall();
} else {
mData.clear();
Snackbar snackbar = Snackbar
.make(recyclerView, "Network Error", Snackbar.LENGTH_INDEFINITE)
.setAction("Retry", new View.OnClickListener() {
@Override
public void onClick(View view) {
refreshMovie();
}
});
snackbar.show();
}
}
/**
* Parsing json reponse and passing the data to feed view list adapter
*/
public void parseJsonFeed(JSONObject response) {
final String POSTER_BEGIN_URL = "http://image.tmdb.org/t/p/w500/";
try {
JSONArray feedArray = response.getJSONArray("results");
for (int i = 0; i < feedArray.length(); i++) {
JSONObject feedObj = (JSONObject) feedArray.get(i);
MovieData item = new MovieData();
item.setTitle(feedObj.getString("original_title"));
// Image might be null sometimes
String image = feedObj.isNull("poster_path") ? null : feedObj
.getString("poster_path");
String POSTER_URL = POSTER_BEGIN_URL + image;
item.setImage(POSTER_URL);
item.setPlot(feedObj.getString("overview"));
item.setRating(feedObj.getString("vote_average"));
item.setReleaseDate(feedObj.getString("release_date"));
mData.add(item);
}
// notify data changes to list adapater
mAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
public void networkCall() {
// We first check for cached request
Cache cache = AppController.getInstance().getRequestQueue().getCache();
String order;
SharedPreferences sharedPrefs =
PreferenceManager.getDefaultSharedPreferences(this);
String orderType = sharedPrefs.getString(
getString(R.string.pref_order_key),
getString(R.string.pref_most_popular));
if (orderType.equals(getString(R.string.pref_top_rated))) {
order = "top_rated";
} else {
order = "popular";
}
String URL_FEED = "https://api.themoviedb.org/3/movie/" + order + "?api_key=" + BuildConfig.OPEN_MOVIE_API_KEY;
Cache.Entry entry = cache.get(URL_FEED);
if (entry != null) {
// fetch the data from cache
try {
String data = new String(entry.data, "UTF-8");
try {
parseJsonFeed(new JSONObject(data));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
// making fresh volley request and getting json
JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.GET,
URL_FEED, null, new Response.Listener() {
@Override
public void onResponse(JSONObject response) {
VolleyLog.d(TAG, "Response: " + response.toString());
if (response != null) {
parseJsonFeed(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
// Adding request to volley request queue
AppController.getInstance().addToRequestQueue(jsonReq);
}
}
@Override
public void itemClicked(View view, int position) {
view.setTransitionName("mImage");
MovieData movie = mData.get(position);
Intent intent = new Intent(this, DisplayActivity.class);
intent.putExtra("MoviePoster", movie.getImage());
intent.putExtra("Title", movie.getTitle());
intent.putExtra("rDate", movie.getReleaseDate());
intent.putExtra("plot", movie.getPlot());
intent.putExtra("rating", movie.getRating());
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(this,view, view.getTransitionName());
getApplicationContext().startActivity(intent,optionsCompat.toBundle());
}
< /code>
} < /p>
Вот активность b < /p>
public class DisplayActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display);
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
TextView nTitle = (TextView) findViewById(R.id.name);
TextView nDate = (TextView) findViewById(R.id.releaseDate);
TextView nRating = (TextView) findViewById(R.id.rating);
TextView nPlot = (TextView) findViewById(R.id.plot);
NetworkImageView nProfilePic = (NetworkImageView) findViewById(R.id.profilePic);
// The detail Activity called via intent. Inspect the intent for data.
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
//intent
String movieImage = bundle.getString("MoviePoster");
//intent
String movieName = bundle.getString("title");
//intent
String movieDate = bundle.getString("rDate");
//intent
String movieRating = bundle.getString("rating");
//intent
String moviePlot = bundle.getString("plot");
//set views
nProfilePic.setImageUrl(movieImage, imageLoader);
nTitle.setText(movieName);
nDate.setText(movieDate);
nRating.setText(movieRating);
nPlot.setText(moviePlot);
}
}
< /code>
} < /p>
Вот logcat < /p>
04-12 14:01:22.349 23413-23413/com.app.sparkimagination.moviesmoviesmovies E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.sparkimagination.moviesmoviesmovies, PID: 23413
java.lang.NullPointerException: A t t e m p t t o i n v o k e v i r t u a l m e t h o d ' v o i d a n d r o i d . w i d g e t . T e x t V i e w . s e t T e x t ( j a v a . l a n g . C h a r S e q u e n c e ) ' o n a n u l l o b j e c t r e f e r e n c e < b r / > a t a d a p t e r . M o v i e s A d a p t e r . o n B i n d V i e w H o l d e r ( M o v i e s A d a p t e r . j a v a : 7 8 ) < b r / > a t a d a p t e r . M o v i e s A d a p t e r . o n B i n d V i e w H o l d e r ( M o v i e s A d a p t e r . j a v a : 2 7 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ A d a p t e r . o n B i n d V i e w H o l d e r ( R e c y c l e r V i e w . j a v a : 6 3 5 6 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ A d a p t e r . b i n d V i e w H o l d e r ( R e c y c l e r V i e w . j a v a : 6 3 8 9 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . t r y B i n d V i e w H o l d e r B y D e a d l i n e ( R e c y c l e r V i e w . j a v a : 5 3 3 5 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . t r y G e t V i e w H o l d e r F o r P o s i t i o n B y D e a d l i n e ( R e c y c l e r V i e w . j a v a : 5 5 9 8 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . g e t V i e w F o r P o s i t i o n ( R e c y c l e r V i e w . j a v a : 5 4 4 0 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . g e t V i e w F o r P o s i t i o n ( R e c y c l e r V i e w . j a v a : 5 4 3 6 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . L i n e a r L a y o u t M a n a g e r $ L a y o u t S t a t e . n e x t ( L i n e a r L a y o u t M a n a g e r . j a v a : 2 2 2 4 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . G r i d L a y o u t M a n a g e r . l a y o u t Chunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThr
< /code>
movie_row Примечание Все остальные представления в держателе находятся в Activity_display xml < /p>
< /code>
отображать XML, где вся информация < /p>
ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
tools:context=".DisplayActivity">
Подробнее здесь: https://stackoverflow.com/questions/433 ... nformation
APP продолжает сбой, пытаясь заполнить активность B другой информацией [дублировать] ⇐ Android
Форум для тех, кто программирует под Android
1739212121
Anonymous
У меня приложение настроено, поэтому, когда я нажимаю на представление об переработке, правильно просмотреть переходы изображений фильма на активность B. Теперь, когда я пытаюсь заполнить информацию об объекте в активности B (например, сюжет и т. Д.) Я получаю Ошибка говорит, что то, что у меня есть в Bindviewholder, является нулевым. Я, должно быть, что -то упускаю, потому что то, как у меня было приложение, настраивалось раньше (вся информация на одной карте) все было запрашивалось правильно и отображалось. Все начало происходить, когда я решил изменить и отправить информацию в действие b. < /P>
Вот адаптер < /p>
public class MoviesAdapter extends RecyclerView.Adapter {
private List moviesList;
private Context context;
private ClickListener clickListener;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public MoviesAdapter(Context context, List moviesList) {
this.moviesList = moviesList;
this.context = context;
}
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView title, plot, releaseDate, rating;
public ImageView thumb;
public NetworkImageView moviePic;
public MyViewHolder(View view) {
super(view);
view.setOnClickListener(this);
title = (TextView) view.findViewById(R.id.name);
plot = (TextView) view.findViewById(R.id.plot);
releaseDate = (TextView) view.findViewById(R.id.releaseDate);
rating = (TextView) view.findViewById(R.id.rating);
thumb = (ImageView) view.findViewById(R.id.thumb);
moviePic = (NetworkImageView) view.findViewById(R.id.profilePic);
}
@Override
public void onClick(View v) {
//context.startActivity(new Intent(context,DisplayActivity.class));
if (clickListener != null) {
clickListener.itemClicked(v, getAdapterPosition());
}
}
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.movie_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
MovieData movie = moviesList.get(position);
holder.title.setText(movie.getTitle());
holder.plot.setText(movie.getPlot());
holder.releaseDate.setText(movie.getReleaseDate());
holder.rating.setText(movie.getRating());
Float nRating = Float.parseFloat(holder.rating.getText().toString());
if (nRating > 6.5) {
holder.thumb.setImageResource(R.drawable.ic_thumbs_up);
} else {
holder.thumb.setImageResource(R.drawable.ic_thumbdown);
}
holder.moviePic.setImageUrl(movie.getImage(), imageLoader);
}
@Override
public int getItemCount() {
return moviesList.size();
}
//Interface and method to help with clicks
public interface ClickListener {
void itemClicked(View view, int position);
}
public void setClickListener(ClickListener clickListener) {
this.clickListener = clickListener;
}
< /code>
Вот MainActivity < /p>
public class MainActivity extends AppCompatActivity implements MoviesAdapter.ClickListener {
private static final String TAG = MainActivity.class.getSimpleName();
static final int SETTINGS_INTENT_REPLY = 1;
private MoviesAdapter mAdapter;
private List mData = new ArrayList();
private RecyclerView recyclerView;
private GridLayoutManager gridLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//check Sdk Level
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mAdapter = new MoviesAdapter(this, mData);
mAdapter.setClickListener(this);
gridLayoutManager = new GridLayoutManager(this,2);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
refreshMovie();
}
@Override
public void onActivityResult(int settingsRequestCode, int settingsResultcode, Intent resultData) {
super.onActivityResult(settingsRequestCode, settingsResultcode, resultData);
if (settingsRequestCode == SETTINGS_INTENT_REPLY) {
refreshMovie();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, 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();
if (id == R.id.action_settings) {
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivityForResult(settingsIntent, SETTINGS_INTENT_REPLY);
return true;
}
return super.onOptionsItemSelected(item);
}
public void refreshMovie() {
// Get a reference to the ConnectivityManager to check state of network connectivity
ConnectivityManager connMgr = (ConnectivityManager)
this.getSystemService(Context.CONNECTIVITY_SERVICE);
// Get details on the currently active default data network
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
// If there is a network connection, fetch data
if (networkInfo != null && networkInfo.isConnected()) {
mData.clear();
networkCall();
} else {
mData.clear();
Snackbar snackbar = Snackbar
.make(recyclerView, "Network Error", Snackbar.LENGTH_INDEFINITE)
.setAction("Retry", new View.OnClickListener() {
@Override
public void onClick(View view) {
refreshMovie();
}
});
snackbar.show();
}
}
/**
* Parsing json reponse and passing the data to feed view list adapter
*/
public void parseJsonFeed(JSONObject response) {
final String POSTER_BEGIN_URL = "http://image.tmdb.org/t/p/w500/";
try {
JSONArray feedArray = response.getJSONArray("results");
for (int i = 0; i < feedArray.length(); i++) {
JSONObject feedObj = (JSONObject) feedArray.get(i);
MovieData item = new MovieData();
item.setTitle(feedObj.getString("original_title"));
// Image might be null sometimes
String image = feedObj.isNull("poster_path") ? null : feedObj
.getString("poster_path");
String POSTER_URL = POSTER_BEGIN_URL + image;
item.setImage(POSTER_URL);
item.setPlot(feedObj.getString("overview"));
item.setRating(feedObj.getString("vote_average"));
item.setReleaseDate(feedObj.getString("release_date"));
mData.add(item);
}
// notify data changes to list adapater
mAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
public void networkCall() {
// We first check for cached request
Cache cache = AppController.getInstance().getRequestQueue().getCache();
String order;
SharedPreferences sharedPrefs =
PreferenceManager.getDefaultSharedPreferences(this);
String orderType = sharedPrefs.getString(
getString(R.string.pref_order_key),
getString(R.string.pref_most_popular));
if (orderType.equals(getString(R.string.pref_top_rated))) {
order = "top_rated";
} else {
order = "popular";
}
String URL_FEED = "https://api.themoviedb.org/3/movie/" + order + "?api_key=" + BuildConfig.OPEN_MOVIE_API_KEY;
Cache.Entry entry = cache.get(URL_FEED);
if (entry != null) {
// fetch the data from cache
try {
String data = new String(entry.data, "UTF-8");
try {
parseJsonFeed(new JSONObject(data));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
// making fresh volley request and getting json
JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.GET,
URL_FEED, null, new Response.Listener() {
@Override
public void onResponse(JSONObject response) {
VolleyLog.d(TAG, "Response: " + response.toString());
if (response != null) {
parseJsonFeed(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
// Adding request to volley request queue
AppController.getInstance().addToRequestQueue(jsonReq);
}
}
@Override
public void itemClicked(View view, int position) {
view.setTransitionName("mImage");
MovieData movie = mData.get(position);
Intent intent = new Intent(this, DisplayActivity.class);
intent.putExtra("MoviePoster", movie.getImage());
intent.putExtra("Title", movie.getTitle());
intent.putExtra("rDate", movie.getReleaseDate());
intent.putExtra("plot", movie.getPlot());
intent.putExtra("rating", movie.getRating());
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(this,view, view.getTransitionName());
getApplicationContext().startActivity(intent,optionsCompat.toBundle());
}
< /code>
} < /p>
Вот активность b < /p>
public class DisplayActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display);
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
TextView nTitle = (TextView) findViewById(R.id.name);
TextView nDate = (TextView) findViewById(R.id.releaseDate);
TextView nRating = (TextView) findViewById(R.id.rating);
TextView nPlot = (TextView) findViewById(R.id.plot);
NetworkImageView nProfilePic = (NetworkImageView) findViewById(R.id.profilePic);
// The detail Activity called via intent. Inspect the intent for data.
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
//intent
String movieImage = bundle.getString("MoviePoster");
//intent
String movieName = bundle.getString("title");
//intent
String movieDate = bundle.getString("rDate");
//intent
String movieRating = bundle.getString("rating");
//intent
String moviePlot = bundle.getString("plot");
//set views
nProfilePic.setImageUrl(movieImage, imageLoader);
nTitle.setText(movieName);
nDate.setText(movieDate);
nRating.setText(movieRating);
nPlot.setText(moviePlot);
}
}
< /code>
} < /p>
Вот logcat < /p>
04-12 14:01:22.349 23413-23413/com.app.sparkimagination.moviesmoviesmovies E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.sparkimagination.moviesmoviesmovies, PID: 23413
java.lang.NullPointerException: A t t e m p t t o i n v o k e v i r t u a l m e t h o d ' v o i d a n d r o i d . w i d g e t . T e x t V i e w . s e t T e x t ( j a v a . l a n g . C h a r S e q u e n c e ) ' o n a n u l l o b j e c t r e f e r e n c e < b r / > a t a d a p t e r . M o v i e s A d a p t e r . o n B i n d V i e w H o l d e r ( M o v i e s A d a p t e r . j a v a : 7 8 ) < b r / > a t a d a p t e r . M o v i e s A d a p t e r . o n B i n d V i e w H o l d e r ( M o v i e s A d a p t e r . j a v a : 2 7 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ A d a p t e r . o n B i n d V i e w H o l d e r ( R e c y c l e r V i e w . j a v a : 6 3 5 6 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ A d a p t e r . b i n d V i e w H o l d e r ( R e c y c l e r V i e w . j a v a : 6 3 8 9 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . t r y B i n d V i e w H o l d e r B y D e a d l i n e ( R e c y c l e r V i e w . j a v a : 5 3 3 5 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . t r y G e t V i e w H o l d e r F o r P o s i t i o n B y D e a d l i n e ( R e c y c l e r V i e w . j a v a : 5 5 9 8 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . g e t V i e w F o r P o s i t i o n ( R e c y c l e r V i e w . j a v a : 5 4 4 0 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . R e c y c l e r V i e w $ R e c y c l e r . g e t V i e w F o r P o s i t i o n ( R e c y c l e r V i e w . j a v a : 5 4 3 6 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . L i n e a r L a y o u t M a n a g e r $ L a y o u t S t a t e . n e x t ( L i n e a r L a y o u t M a n a g e r . j a v a : 2 2 2 4 ) < b r / > a t a n d r o i d . s u p p o r t . v 7 . w i d g e t . G r i d L a y o u t M a n a g e r . l a y o u t Chunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16630)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThr
< /code>
movie_row Примечание Все остальные представления в держателе находятся в Activity_display xml < /p>
< /code>
отображать XML, где вся информация < /p>
ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
tools:context=".DisplayActivity">
Подробнее здесь: [url]https://stackoverflow.com/questions/43376627/app-keeps-crashing-when-trying-to-populate-activity-b-with-other-information[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия