-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8469a95
commit bdc96a2
Showing
4 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# 🗨 AlertDialog | ||
|
||
## 🕐 Zaman Seçme | ||
|
||
```java | ||
public static class TimePickerFragment extends DialogFragment | ||
implements TimePickerDialog.OnTimeSetListener { | ||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
// Use the current time as the default values for the picker | ||
final Calendar c = Calendar.getInstance(); | ||
int hour = c.get(Calendar.HOUR_OF_DAY); | ||
int minute = c.get(Calendar.MINUTE); | ||
// Create a new instance of TimePickerDialog and return it | ||
return new TimePickerDialog(getActivity(), this, hour, minute, | ||
DateFormat.is24HourFormat(getActivity())); | ||
} | ||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { | ||
// Do something with the time chosen by the user | ||
} | ||
} | ||
``` | ||
|
||
```markup | ||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/pick_time" | ||
android:onClick="showTimePickerDialog" /> | ||
``` | ||
|
||
```java | ||
public void showTimePickerDialog(View v) { | ||
DialogFragment newFragment = new TimePickerFragment(); | ||
newFragment.show(getSupportFragmentManager(), "timePicker"); | ||
} | ||
``` | ||
|
||
## 📅 Tarih Seçme | ||
|
||
```java | ||
public static class DatePickerFragment extends DialogFragment | ||
implements DatePickerDialog.OnDateSetListener { | ||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
// Use the current date as the default date in the picker | ||
final Calendar c = Calendar.getInstance(); | ||
int year = c.get(Calendar.YEAR); | ||
int month = c.get(Calendar.MONTH); | ||
int day = c.get(Calendar.DAY_OF_MONTH); | ||
// Create a new instance of DatePickerDialog and return it | ||
return new DatePickerDialog(getActivity(), this, year, month, day); | ||
} | ||
public void onDateSet(DatePicker view, int year, int month, int day) { | ||
// Do something with the date chosen by the user | ||
} | ||
} | ||
``` | ||
|
||
```markup | ||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/pick_date" | ||
android:onClick="showDatePickerDialog" /> | ||
``` | ||
|
||
```java | ||
public void showDatePickerDialog(View v) { | ||
DialogFragment newFragment = new DatePickerFragment(); | ||
newFragment.show(getSupportFragmentManager(), "datePicker"); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# 🗂️ RcycleView | ||
|
||
## 📦 Bağımlılıkları Dahil Etme | ||
|
||
```text | ||
dependencies { | ||
implementation 'com.android.support:recyclerview-v7:28.0.0' | ||
} | ||
``` | ||
|
||
## 📝 XML Dosyasında Tanımlama | ||
|
||
```text | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- A RecyclerView with some commonly used attributes --> | ||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/my_recycler_view" | ||
android:scrollbars="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
``` | ||
|
||
## 📃 Activity Üzerinde Tanımlama | ||
|
||
```java | ||
public class MyActivity extends Activity { | ||
private RecyclerView recyclerView; | ||
private RecyclerView.Adapter mAdapter; | ||
private RecyclerView.LayoutManager layoutManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.my_activity); | ||
recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); | ||
|
||
// use this setting to improve performance if you know that changes | ||
// in content do not change the layout size of the RecyclerView | ||
recyclerView.setHasFixedSize(true); | ||
|
||
// use a linear layout manager | ||
layoutManager = new LinearLayoutManager(this); | ||
recyclerView.setLayoutManager(layoutManager); | ||
|
||
// specify an adapter (see also next example) | ||
mAdapter = new MyAdapter(myDataset); | ||
recyclerView.setAdapter(mAdapter); | ||
} | ||
// ... | ||
} | ||
``` | ||
|
||
## 📂 Adapter Sınıfı | ||
|
||
```java | ||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> { | ||
private String[] mDataset; | ||
|
||
// Provide a reference to the views for each data item | ||
// Complex data items may need more than one view per item, and | ||
// you provide access to all the views for a data item in a view holder | ||
public static class MyViewHolder extends RecyclerView.ViewHolder { | ||
// each data item is just a string in this case | ||
public TextView textView; | ||
public MyViewHolder(TextView v) { | ||
super(v); | ||
textView = v; | ||
} | ||
} | ||
|
||
// Provide a suitable constructor (depends on the kind of dataset) | ||
public MyAdapter(String[] myDataset) { | ||
mDataset = myDataset; | ||
} | ||
|
||
// Create new views (invoked by the layout manager) | ||
@Override | ||
public MyAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, | ||
int viewType) { | ||
// create a new view | ||
TextView v = (TextView) LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.my_text_view, parent, false); | ||
... | ||
MyViewHolder vh = new MyViewHolder(v); | ||
return vh; | ||
} | ||
|
||
// Replace the contents of a view (invoked by the layout manager) | ||
@Override | ||
public void onBindViewHolder(MyViewHolder holder, int position) { | ||
// - get element from your dataset at this position | ||
// - replace the contents of the view with that element | ||
holder.textView.setText(mDataset[position]); | ||
|
||
} | ||
|
||
// Return the size of your dataset (invoked by the layout manager) | ||
@Override | ||
public int getItemCount() { | ||
return mDataset.length; | ||
} | ||
} | ||
``` | ||
|
||
## 🔗 Faydalı Bağlantılar | ||
|
||
{% embed url="https://developer.android.com/guide/topics/ui/layout/recyclerview" %} | ||
|