کد:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_gravity="right"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:src="@drawable/ic_launcher_background">
</ImageView>
<TextView
android:id="@+id/textitem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorTT"
android:textSize="100px"
/>
</android.support.constraint.ConstraintLayout>
کد:
<?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=".MainActivity"
android:layout_gravity="right"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/header"
android:background="#FC9"
android:orientation="horizontal">
<Button
android:paddingLeft="10dp"
android:paddingStart="10dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/BtnAdd"
android:layout_margin="4dp"
android:textSize="18sp"
android:textColor="#000"/>
<EditText
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/textInput"
android:layout_toRightOf="@+id/Drive_Number"
android:layout_margin="4dp"
android:textSize="18sp"
android:textColor="#000"/>
<TextView
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:gravity="right"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/Drive_Time"
android:layout_toRightOf="@+id/Drive_Distance"
android:layout_margin="4dp"
android:textSize="18sp"
android:textColor="#000"/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:layout_below="@+id/header"
android:textDirection="rtl"
android:id="@+id/scrollableContents">
<ListView
android:id="@+id/lstv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textDirection="rtl"
/>
</RelativeLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
کد:
<?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_gravity="right"
android:layout_height="match_parent">
<TextView
android:id="@+id/textm1001"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textColor="@color/colorAccent"
android:textSize="100px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="64dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textm1001"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="236dp" />
</android.support.constraint.ConstraintLayout>
کد:
package com.example.dial.dial;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import static java.security.AccessController.getContext;
public class MainActivity extends AppCompatActivity {
private ArrayList<String> arrayList;
private ArrayAdapter<String> arrayAdapter;
private EditText inputText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView = (ListView)findViewById(R.id.lstv);
String[] item = {"علی" , "امید" , "زمان"};
arrayList = new ArrayList<>(Arrays.asList(item));
for (int i = 0; i<= 20;i++)
{
arrayList.add("علی" + Integer.toString(i));
}
arrayAdapter = new ArrayAdapter<String>(this,R.layout.list_item , R.id.textitem , arrayList);
listView.setAdapter(arrayAdapter);
inputText = (EditText)findViewById(R.id.textInput);
Button button = (Button)findViewById(R.id.BtnAdd);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String newItem = inputText.getText().toString();
arrayList.add(newItem);
arrayAdapter.notifyDataSetChanged();
}
});
UDF_ShoDial();
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), "sdfdsf = " + position, Toast.LENGTH_LONG).show();
UDF_ShoDial();
return true;
}
});
}
protected void UDF_ShoDial()
{
try {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
View mView = getLayoutInflater().inflate(R.layout.dial_main2 , null);
TextView textView = (TextView)mView.findViewById(R.id.textm1001);
textView.setText("تعداد 3000 رکورد درج شد.");
builder.setView(mView);
AlertDialog dialog = builder.create();
dialog.show();
} catch (Exception e) {
/*TextView textView3 = (TextView)findViewById(R.id.pptr);
textView3.setText(e.getMessage().toString());*/
}
}
}