英文:
Android CardView implementation
问题
我创建了一个带有列表视图的Android应用程序。每当点击一个元素时,它会传递意图到卡片视图。我的布局文件中只有一个单独的卡片视图,并且对于列表视图中的每个元素都使用它。
对于每个列表项,在Java中为CardView定义了不同的实现,从一个Java文件传递意图到另一个文件。
请问这样做是一种好的做法吗?即在多个元素上使用单个卡片视图和RecyclerView,并在程序中更改它们的文本。我还没有看到有人这样做过。
编辑
@Ankit,类似于...
类似于
<android.support.v7.widget.RecyclerView/>
</LinearLayout>```
**教程页面1**
```public class Lesson_Galaxy_One extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
**教程页面2**
```public class Lesson_Galaxy_Two extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
**教程页面3**
```public class Lesson_Galaxy_Three extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
每个页面都有不同的元素用于RecyclerView的CardView,从一个页面传递意图到另一个页面。
<details>
<summary>英文:</summary>
I created an Android app with list view. Whenever the an element is clicked, it passes intent to cardview.I have a single cardview in my layout file, and use it for every element in the listView.
For each list item, I define different implementation for the CardView in Java passing intents from one java file to the other. .
Please is this a good practice using a single card view and Recycler View for multiple elements changing their text programmatically. I haven't seen anyone do something like that.
**Edit**
@Ankit something like ...
Something like
```<LinearLayout
>
<android.support.v7.widget.RecyclerView/>
</LinearLayout>```
**Tutorial page 1**
```public class Lesson_Galaxy_One extends AppCompatActivity
{ super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
**Tutorial 2**
```public class Lesson_Galaxy_Two extends AppCompatActivity
{ super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
**Tutorial 3**
```public class Lesson_Galaxy_Three extends AppCompatActivity
{ super.onCreate(savedInstanceState);
setContentView(R.layout.lesson_galaxy);
}```
Each with different elements for the RecyclerView's CardView with intents being passed from one to the other.
</details>
# 答案1
**得分**: 1
不会有任何问题,可以将单个卡片视图用于多个列表项。这完全没有问题。
<details>
<summary>英文:</summary>
There won't be any issues of using a single card view for multiple list items.It's totally fine .
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论