Мой переработчикПросмотр не отображается.В чем моя проблема?
// ТЕКСТ Мой ресайлер не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема? Мой реселлерПросмотр не отображается.В чем моя проблема?// TEXT
activity_add.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.mkurbanov.lebap_kwartira.ui.AddActivity">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@drawable/edit_text_bg"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_title_black_48dp"
android:tint="@color/enabled" />
<EditText
android:id="@+id/edit_add_home_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="Siz näme goşýarsyňyz?"
android:maxLength="60"
android:maxLines="1"
android:padding="7dp"
android:textColor="@color/enabled"
android:textColorHint="@color/disabled"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@drawable/edit_text_bg"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_text_format_black_48dp"
android:tint="@color/enabled" />
<EditText
android:id="@+id/edit_add_home_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="Bildiriş hakynda düşündiriş ýazyň"
android:maxLength="200"
android:padding="7dp"
android:textColor="@color/enabled"
android:textColorHint="@color/disabled"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@drawable/edit_text_bg"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_account_balance_wallet_black_48dp"
android:tint="@color/enabled" />
<EditText
android:id="@+id/edit_add_home_money"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="Baha goýuň"
android:inputType="number"
android:maxLength="10"
android:maxLines="1"
android:padding="7dp"
android:textColor="@color/enabled"
android:textColorHint="@color/disabled"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@drawable/edit_text_bg"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_phone_black_48dp"
android:tint="@color/enabled" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:text="+993"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="@+id/edit_add_home_phone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:hint="Telefon belgiňiz"
android:inputType="number"
android:maxLength="8"
android:padding="7dp"
android:textColor="@color/enabled"
android:textColorHint="@color/disabled"
android:textSize="18sp" />
</LinearLayout>
<FrameLayout
android:id="@+id/fl_add_home_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:background="@drawable/edit_text_bg"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="left"
android:src="@drawable/ic_bubble_chart_black_48dp"
android:tint="@color/enabled" />
<TextView
android:id="@+id/tv_add_home_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Kategoriýa saýlaň"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceListItem" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="right"
android:src="@drawable/ic_expand_more_black_48dp" />
</FrameLayout>
<!-- this is RecyclerView -->
<android.support.v7.widget.RecyclerView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@drawable/edit_text_bg"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:padding="8dp">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="left|center"
android:src="@drawable/ic_room_black_48dp"
android:tint="@color/enabled" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="right|center"
android:src="@drawable/ic_expand_more_black_48dp" />
<LinearLayout
android:id="@+id/ll_add_home_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:text="Ýer saýla" />
<TextView
android:id="@+id/tv_add_home_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:padding="2dp"
android:text="Ýerleşýän ýeri"
android:textAppearance="?android:attr/textAppearanceListItem" />
</LinearLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin">
<Button
android:id="@+id/btn_add_home_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/btn_empty_solid"
android:foreground="?attr/selectableItemBackground"
android:text="@string/add_home"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
AddActivity.java:
package com.mkurbanov.lebap_kwartira.ui;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.mkurbanov.degishmeler.R;
import com.mkurbanov.lebap_kwartira.Data;
import com.mkurbanov.lebap_kwartira.adapter.AddAdapter;
import com.mkurbanov.lebap_kwartira.interfaces.ListItem;
import com.mkurbanov.lebap_kwartira.model.Edit;
import com.mkurbanov.lebap_kwartira.model.Line;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
import java.util.ArrayList;
public class AddActivity extends AppCompatActivity implements View.OnKeyListener, View.OnClickListener {
Data data;
EditText editTitle, editText, editMoney;
TextView tvCategory, tvLocation;
Button btnAdd;
FrameLayout flHomeCategory;
LinearLayout llLocation;
RecyclerView recyclerView;
final int DIALOG_HOMES = 1, DIALOG_LOCATIONS = 2;
String ITEM_HOMES[], ITEM_LOCATIONS[];
ArrayList<ListItem> items = new ArrayList<ListItem>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
data = new Data(this);
editTitle = (EditText) findViewById(R.id.edit_add_home_title);
editText = (EditText) findViewById(R.id.edit_add_home_text);
editMoney = (EditText) findViewById(R.id.edit_add_home_money);
btnAdd = (Button) findViewById(R.id.btn_add_home_add);
tvCategory = (TextView) findViewById(R.id.tv_add_home_category);
tvLocation = (TextView) findViewById(R.id.tv_add_home_location);
flHomeCategory = (FrameLayout) findViewById(R.id.fl_add_home_category);
llLocation = (LinearLayout) findViewById(R.id.ll_add_home_location);
ITEM_HOMES = getResources().getStringArray(R.array.homes);
ITEM_LOCATIONS = getResources().getStringArray(R.array.locations);
recyclerView = (RecyclerView) findViewById(R.id.rc);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
AddAdapter adapter = new AddAdapter(items, this);
for (int i = 0; i < 20; i++){
items.add(new Edit(R.drawable.ic_title_black_48dp, 20, "Siz nämeler goşýarsyňyz?"));
if (i % 3 == 0)
items.add(new Line());
}
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setNestedScrollingEnabled(true);
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).build());
editTitle.setOnKeyListener(this);
editText.setOnKeyListener(this);
editMoney.setOnKeyListener(this);
flHomeCategory.setOnClickListener(this);
llLocation.setOnClickListener(this);
btnAdd.setOnClickListener(this);
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (v.getId()) {
case R.id.edit_add_home_title:
if (keyCode == 66)
return true;
break;
case R.id.edit_add_home_money:
break;
}
return false;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, getResources().getText(R.string.cancel)).setIcon(R.drawable.ic_clear_white_48dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return super.onCreateOptionsMenu(menu);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_add_home_add:
data.toast(getText(R.string.sended), 1);
break;
case R.id.fl_add_home_category:
showDialog(DIALOG_HOMES);
break;
case R.id.ll_add_home_location:
showDialog(DIALOG_LOCATIONS);
break;
}
}
@Override
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder adb = new AlertDialog.Builder(this);
switch (id) {
case DIALOG_HOMES:
adb.setTitle(getString(R.string.homes));
adb.setItems(ITEM_HOMES, dialogHomesOnClick);
return adb.create();
case DIALOG_LOCATIONS:
adb.setTitle(getString(R.string.location));
adb.setItems(ITEM_LOCATIONS, dialogLocationOnClick);
return adb.create();
}
return super.onCreateDialog(id);
}
DialogInterface.OnClickListener dialogHomesOnClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tvCategory.setText(ITEM_HOMES[which]);
}
};
DialogInterface.OnClickListener dialogLocationOnClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tvLocation.setText(ITEM_LOCATIONS[which]);
}
};
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
finish();
}
return super.onOptionsItemSelected(item);
}
}
AddAdapter.java:
package com.mkurbanov.lebap_kwartira.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import com.mkurbanov.degishmeler.R;
import com.mkurbanov.lebap_kwartira.Data;
import com.mkurbanov.lebap_kwartira.interfaces.ListItem;
import com.mkurbanov.lebap_kwartira.model.Edit;
import java.util.ArrayList;
/**
* Created by Mukam Kurbanov on 18.12.2018.
*/
public class AddAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
ArrayList<ListItem> items;
Context context;
LayoutInflater layoutInflater;
Data data;
public AddAdapter(ArrayList<ListItem> items, Context context) {
this.items = items;
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
this.data = new Data(context);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case ListItem.TYPE_EDIT_TEXT:
View view = layoutInflater.inflate(R.layout.item_add_edit, parent, false);
VHEditText vhEditText = new VHEditText(view, new MyCustomEditTextListener());
return vhEditText;
case ListItem.TYPE_LINE:
View v = layoutInflater.inflate(R.layout.line, parent, false);
return new VHLine(v);
}
return null;
}
@Override
public int getItemViewType(int position) {
return items.get(position).getItemType();
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof VHEditText) {
VHEditText vhEditText = (VHEditText) holder;
final Edit edit = (Edit) items.get(position);
vhEditText.imageView.setImageResource(edit.getImage());
vhEditText.editText.setHint(edit.getHintText());
vhEditText.editText.setMaxLines(1);
vhEditText.editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(edit.getMaxLength())});
vhEditText.myCustomEditTextListener.updatePosition(holder.getAdapterPosition());
vhEditText.editText.setText(((Edit) items.get(vhEditText.getAdapterPosition())).getText());
}
}
@Override
public int getItemCount() {
return items.size();
}
class VHEditText extends RecyclerView.ViewHolder {
final ImageView imageView;
final EditText editText;
public MyCustomEditTextListener myCustomEditTextListener;
public VHEditText(View itemView, MyCustomEditTextListener myCustomEditTextListener) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.image);
editText = (EditText) itemView.findViewById(R.id.edit_text);
this.myCustomEditTextListener = myCustomEditTextListener;
editText.addTextChangedListener(myCustomEditTextListener);
}
}
class VHLine extends RecyclerView.ViewHolder {
public VHLine(View itemView) {
super(itemView);
}
}
private class MyCustomEditTextListener implements TextWatcher {
private int position;
public void updatePosition(int position) {
this.position = position;
}
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
// no op
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
((Edit) items.get(position)).setText(charSequence.toString());
}
@Override
public void afterTextChanged(Editable editable) {
// no op
}
}
}