質問編集履歴

3

文法の修正

2022/12/09 01:47

投稿

footrest
footrest

スコア1

test CHANGED
File without changes
test CHANGED
@@ -124,8 +124,6 @@
124
124
  }
125
125
  AsyncHttpRequest2 task = new AsyncHttpRequest2((Activity) v.getContext());
126
126
  task.execute(url);
127
- AsyncHttpRequest2 task2 = new AsyncHttpRequest2((Activity) v.getContext());
128
- task2.execute(url);
129
127
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
130
128
  ((Activity) v.getContext()).finish();
131
129
  SakuhinIchiranActivity.sakka.clear();

2

コードを差し替え

2022/12/08 05:57

投稿

footrest
footrest

スコア1

test CHANGED
File without changes
test CHANGED
@@ -88,10 +88,10 @@
88
88
  ```
89
89
  ②の表示、クリックリスナーを担うRecyclerViewAdapter
90
90
  ```Java
91
- public class AtoWaRecyclerviewAdapter3 extends RecyclerView.Adapter<AtoWaRecyclerViewHolder>{
91
+ public class SakuhinIchiranRecyclerviewAdapter extends RecyclerView.Adapter<AtoWaRecyclerViewHolder>{
92
92
  private List<RowData> list;
93
93
 
94
- public AtoWaRecyclerviewAdapter3(List<RowData> list){
94
+ public SakuhinIchiranRecyclerviewAdapter(List<RowData> list){
95
95
  this.list = list;
96
96
  }
97
97
 
@@ -110,23 +110,26 @@
110
110
  holder.itemView.setOnClickListener(new View.OnClickListener() {
111
111
  @Override
112
112
  public void onClick(View v) {
113
- Intent intent = new Intent(v.getContext(), SakuhinIchiranActivity.class);
113
+ Intent intent = new Intent(v.getContext(), ReadfromSakuhinmeiActivity.class);
114
114
  int position = holder.getLayoutPosition();
115
- String[] persons1 = {"", "k", "s", "t", "n", "h", "m", "y", "r", "w"};
115
+ String sakkaSeq = SakuhinIchiranActivity.sakka.get(position);
116
- String[] persons2 = {"a", "i", "u", "e", "o"};
116
+ String cardSeq = SakuhinIchiranActivity.card.get(position);
117
- String urltext = "https://www.aozora.gr.jp/index_pages/sakuhin_" + persons1[SakuhinActivity2.shiin] + persons2[position] + "1.html";
117
+ String firstURL = "https://www.aozora.gr.jp/cards/" + sakkaSeq +"/" + cardSeq + ".html";
118
+ intent.putExtra("sakka", sakkaSeq);
118
119
  URL url = null;
119
120
  try {
120
- url = new URL(urltext);
121
+ url = new URL(firstURL);
121
122
  } catch (MalformedURLException e) {
122
123
  e.printStackTrace();
123
124
  }
124
-
125
+ AsyncHttpRequest2 task = new AsyncHttpRequest2((Activity) v.getContext());
126
+ task.execute(url);
125
- AsyncHttpRequest task1 = new AsyncHttpRequest((Activity) v.getContext());
127
+ AsyncHttpRequest2 task2 = new AsyncHttpRequest2((Activity) v.getContext());
126
- task1.execute(url);
128
+ task2.execute(url);
127
-
128
129
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
129
130
  ((Activity) v.getContext()).finish();
131
+ SakuhinIchiranActivity.sakka.clear();
132
+ SakuhinIchiranActivity.card.clear();
130
133
  v.getContext().startActivity(intent);
131
134
 
132
135
  }

1

書式の改善

2022/12/08 05:24

投稿

footrest
footrest

スコア1

test CHANGED
File without changes
test CHANGED
@@ -25,8 +25,8 @@
25
25
 
26
26
 
27
27
  ### 該当のソースコード
28
-
29
- ```Java(webファイル取得)
28
+ (webファイル取得)
29
+ ```Java
30
30
  public class AsyncHttpRequest extends AsyncTask<URL, Void, String> {
31
31
  private Activity mainActivity;
32
32
  protected String resultText;
@@ -86,8 +86,8 @@
86
86
 
87
87
  }
88
88
  ```
89
-
90
- ```Java,②の表示、クリックリスナーを担うRecyclerViewAdapter
89
+ ②の表示、クリックリスナーを担うRecyclerViewAdapter
90
+ ```Java
91
91
  public class AtoWaRecyclerviewAdapter3 extends RecyclerView.Adapter<AtoWaRecyclerViewHolder>{
92
92
  private List<RowData> list;
93
93
 
@@ -140,7 +140,8 @@
140
140
  }
141
141
 
142
142
  ```
143
- ```Java(③のアクティビティ)
143
+ ③のアクティビティ
144
+ ```Java
144
145
  public class SakuhinIchiranActivity extends AppCompatActivity {
145
146
  public static List<String> sakka = new ArrayList<>();//④でのURL生成用のリスト
146
147
  public static List<String> card = new ArrayList<>();//④でのURL生成用