In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian for you to introduce in detail "Android mobile development recycleView page click jump how to achieve", the content is detailed, the steps are clear, the details are handled properly, I hope that this "Android mobile development recycleView page click jump how to achieve" article can help you solve doubts, the following with the editor's ideas slowly in-depth, together to learn new knowledge.
one。 Purpose
Review the process and results of the previous two times, as well as the task and the final effect view:
(1) implement interface design and interface jump for the first time. Examples are as follows:
(2) the second time is to design and implement my favorite layout in the page. I implement the layout of waterfall flow, as follows:
(3) the third time is this task: the Activity page is redirected (the recycleView page is redirected by clicks). The results are as follows:
two。 Specific code and page introduction
1. Edit details page
The style, code and style diagram of the clicked interface are as follows:
Because my entire interface is some good-looking pictures, I think it is more important to enlarge the picture and watch it better. Here we also use the same way to enlarge and shrink the picture in the same proportion as before. You can analyze it according to your own specific content. Show it in the new Activity
/ / this activity is used to display the activitypublic class CardInfoActivity extends AppCompatActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_card_info); / / get the passed information ImageView card_info_image= (ImageView) findViewById (R.id.card_info_image); TextView card_info_title= (TextView) findViewById (R.id.card_info_title) Intent intent=getIntent (); Bundle bundle=intent.getExtras (); card_info_image.setImageResource (bundle.getInt ("cardImageId")); card_info_title.setText (bundle.getString ("cardTitle")); / / modify the height of the image ViewGroup.LayoutParams params = card_info_image.getLayoutParams () / / TODO obviously, this height is determined by this parameter. If we know the width of the width, then we can know the actual zoom ratio / / get the width of the screen int screenWidth = ScreenUtil.getScreenWidth (this); / / Log.d ("height", String.valueOf (screenWidth)) / / adjust the size of the picture to ensure that the width must be half of the screen, and the height changes as you zoom float scale = (float) bundle.getInt ("height") / (float) bundle.getInt ("width"); params.height = (int) (screenWidth * scale) + 200; card_info_image.setLayoutParams (params);}}
two。 Add click-to-jump function to the original Fragment page (home page) (this is WechatFragment)
/ / set Item snooping myadapter.setOnRecyclerItemClickListener of Myadapter (new OnRecyclerItemClickListener () {@ Override public void onItemClick (int Position, List cards) {/ * to another activity * / Intent intent=new Intent (getActivity (), CardInfoActivity.class) / / pass the corresponding parameters / / We need to pass the information that makes up a picture to Bundle bundle=new Bundle (); bundle.putInt ("cardImageId", cards.get (Position). GetImageId ()); bundle.putString ("cardTitle", cards.get (Position). GetTitle ()) Bundle.putInt ("height", cards.get (Position). GetHeight ()); bundle.putInt ("width", cards.get (Position). GetWidth ()); intent.putExtras (bundle) / / enable the activity transition of the shared component / / the selected shared component, which is the component of the current page / / gets the ViewHolder Log.d of item ("myposition-firstPo", Arrays.toString (firstStaggeredGridPosition)); Log.d ("myposition-actPo", String.valueOf (Position)) Log.d ("myposition-lastPo", Arrays.toString (lastStaggeredGridPosition)); / / because I am using StaggeredGridLayoutManager RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager (); / / because the waterfall flow is two columns, here is to get the minimum value int realFirstPosition=Math.min on the page (firstStaggeredGridPosition [0], firstStaggeredGridPosition [1]) Myadapter.MyViewHolder viewHolder= (Myadapter.MyViewHolder) recyclerView.getChildViewHolder (recyclerView.getChildAt (Position-realFirstPosition)); ImageView card_info_image= viewHolder.inserimage; ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation (getActivity (), Pair.create (card_info_image, "card_info_image")); startActivity (intent,options.toBundle ()) })
Design snooping Interface in Myadapter
/ / customize the click event of the interface interface OnRecyclerItemClickListener {/ / RecyclerView, and call back the information to view void onItemClick (int Position, List datas) } after reading this, the article "how to click and jump on the page of Android mobile development recycleView" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.