Skip to content

Commit 2e38673

Browse files
author
SamsetDev
committed
add recyclerview
1 parent a96834a commit 2e38673

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

.idea/misc.xml

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/samset/retrooffline/ui/MainActivity.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import androidx.appcompat.app.AppCompatActivity;
44
import androidx.appcompat.widget.AppCompatButton;
55
import androidx.appcompat.widget.AppCompatTextView;
6+
import androidx.recyclerview.widget.RecyclerView;
67
import retrofit2.Call;
78
import retrofit2.Callback;
89
import retrofit2.Response;
@@ -28,7 +29,7 @@ public class MainActivity extends AppCompatActivity {
2829
RetrofitManager manager;
2930
private ApiService apiService;
3031
private ProgressBar progressBar;
31-
private AppCompatTextView tvdata;
32+
private RecyclerView recyclerview;
3233
private AppCompatButton btnget;
3334
public static ArrayList<JSONResponses> data;
3435

@@ -39,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
3940
setContentView(R.layout.activity_main);
4041
progressBar = findViewById(R.id.progress);
4142
btnget = findViewById(R.id.btngetdata);
42-
tvdata = findViewById(R.id.tvdata);
43+
recyclerview = findViewById(R.id.recyclerview);
4344
manager = new RetrofitManager(this);
4445
apiService = manager.getApiService();
4546

@@ -63,7 +64,7 @@ public void onResponse(Call<List<BasicResponse>> call, Response<List<BasicRespon
6364
progressBar.setVisibility(View.GONE);
6465
List<BasicResponse> repos = response.body();
6566
Log.e("TAG", " response " + repos.size());
66-
tvdata.setText(repos.get(0).getName());
67+
//tvdata.setText(repos.get(0).getName());
6768
// listView.setAdapter(new GitHubRepoAdapter(MainActivity.this, -1, repos));
6869
}
6970

app/src/main/res/layout/activity_main.xml

+13-12
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,38 @@
66
android:layout_height="match_parent"
77
tools:context=".ui.MainActivity">
88

9-
<androidx.appcompat.widget.AppCompatTextView
10-
android:id="@+id/tvdata"
11-
android:layout_width="wrap_content"
12-
android:layout_height="wrap_content"
13-
android:layout_marginTop="@dimen/_40sdp"
14-
android:text="Loading..."
15-
app:layout_constraintLeft_toLeftOf="parent"
16-
app:layout_constraintRight_toRightOf="parent"
17-
app:layout_constraintTop_toTopOf="parent" />
189

1910
<androidx.appcompat.widget.AppCompatButton
2011
android:id="@+id/btngetdata"
2112
android:layout_width="wrap_content"
2213
android:layout_height="wrap_content"
23-
android:layout_marginTop="@dimen/_40sdp"
14+
android:layout_marginTop="@dimen/_5sdp"
2415
android:paddingLeft="@dimen/_40sdp"
2516
android:paddingTop="@dimen/_10sdp"
2617
android:paddingRight="@dimen/_40sdp"
2718
android:paddingBottom="@dimen/_10sdp"
2819
android:text="Get data"
2920
app:layout_constraintLeft_toLeftOf="parent"
3021
app:layout_constraintRight_toRightOf="parent"
31-
app:layout_constraintTop_toBottomOf="@+id/tvdata" />
22+
app:layout_constraintTop_toTopOf="parent" />
23+
24+
25+
<androidx.recyclerview.widget.RecyclerView
26+
android:id="@+id/recyclerview"
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:layout_marginTop="@dimen/_5sdp"
30+
app:layout_constraintLeft_toLeftOf="parent"
31+
app:layout_constraintRight_toRightOf="parent"
32+
app:layout_constraintTop_toBottomOf="@+id/btngetdata" />
3233

3334

3435
<ProgressBar
3536
android:id="@+id/progress"
36-
android:visibility="gone"
3737
android:layout_width="wrap_content"
3838
android:layout_height="wrap_content"
3939
android:layout_gravity="center"
40+
android:visibility="gone"
4041
app:layout_constraintBottom_toBottomOf="parent"
4142
app:layout_constraintLeft_toLeftOf="parent"
4243
app:layout_constraintRight_toRightOf="parent"

0 commit comments

Comments
 (0)