set wallet adapter and listView

This commit is contained in:
GME 2019-04-10 23:28:19 +02:00
parent 389886f3c6
commit d4d3eaf5ed
6 changed files with 168 additions and 50 deletions

View file

@ -36,7 +36,8 @@ public class SelectWalletActivity extends AppCompatActivity {
}
Log.i("SelectWalletActivity", "userWallets : "+userWallets);
ArrayAdapter<Wallet> adapter = new ArrayAdapter<Wallet>(this, R.layout.activity_select_wallet, userWallets);
WalletAdapter adapter = new WalletAdapter(this,userWallets);
//ArrayAdapter<Wallet> adapter = new ArrayAdapter<Wallet>(this, R.layout.activity_select_wallet, userWallets);
listView.setAdapter(adapter);
//TODO

View file

@ -0,0 +1,41 @@
package monnethic.mobile.wallet;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.example.monnthic.monnethicmobile.R;
import java.util.ArrayList;
public class WalletAdapter extends ArrayAdapter<Wallet> {
public WalletAdapter(Context context, ArrayList<Wallet> wallets){
super(context,0,wallets);
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
Wallet wallet = getItem(position);
if(convertView == null){
convertView = LayoutInflater.from(getContext()).inflate(R.layout.wallet_view_template, parent, false);
}
TextView wallet_hash = (TextView) convertView.findViewById(R.id.wallet_hash);
TextView wallet_type = (TextView) convertView.findViewById(R.id.wallet_type);
TextView wallet_balance = (TextView) convertView.findViewById(R.id.wallet_balance);
ViewGroup.LayoutParams params = convertView.getLayoutParams();
params.height = 300;
convertView.setLayoutParams(params);
wallet_hash.setText(wallet.getWallet_hash());
wallet_type.setText(wallet.getType());
wallet_balance.setText(String.valueOf(wallet.getBalance()));
return convertView;
}
}

View file

@ -1,60 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="monnethic.mobile.wallet.CreateWalletActivity">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fillViewport="true"
>
android:layout_marginStart="0dp"
android:layout_marginTop="0dp">
<EditText
android:id="@+id/editTextWalletType"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="168dp"
android:layout_marginEnd="32dp"
android:ems="10"
android:hint="Wallet name"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginBottom="188dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:id="@+id/buttonCancel"
android:layout_width="wrap_content"
<EditText
android:id="@+id/editTextWalletType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="86dp"
android:layout_marginTop="0dp"
android:text="Cancel" />
android:ems="10"
android:gravity="center"
android:hint="Wallet name"
android:inputType="text" />
<Button
android:id="@+id/buttonOk"
android:layout_width="wrap_content"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/buttonCancel"
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:layout_marginEnd="86dp"
android:text="OK" />
</RelativeLayout>
android:layout_marginTop="40dp"
android:layout_marginBottom="20dp">
<Button
android:id="@+id/buttonValidate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:layout_marginEnd="30dp"
android:text="Validate" />
<Button
android:id="@+id/buttonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="30dp"
android:layout_marginTop="0dp"
android:text="Cancel" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
</RelativeLayout>

View file

@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="200dp"
android:layout_marginTop="220dp"
android:layout_marginEnd="32dp"
android:text="CREATE WALLET"
app:layout_constraintEnd_toEndOf="parent"
@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="200dp"
android:layout_marginBottom="220dp"
android:text="SELECT WALLET"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View file

@ -17,6 +17,7 @@
<ListView
android:id="@+id/listViewWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:dividerHeight="5dp" />
</ScrollView>
</android.support.constraint.ConstraintLayout>

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/wallet_hash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:text="Wallet Hash"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textSize="10sp" />
<TextView
android:id="@+id/wallet_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/wallet_hash"
android:layout_alignStart="@+id/wallet_balance"
android:layout_marginStart="0dp"
android:layout_marginTop="9dp"
android:text="Wallet Type"
android:textSize="12sp" />
<TextView
android:id="@+id/wallet_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="112dp"
android:layout_marginTop="52dp"
android:text="Wallet Balance"
android:textSize="12sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/wallet_type"
android:layout_marginEnd="-85dp"
android:layout_toStartOf="@+id/wallet_balance"
android:text="Wallet :"
android:textSize="12sp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView2"
android:layout_alignTop="@+id/wallet_balance"
android:text="Balance :"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>