Search This Blog

Popular Posts

Saturday, October 31, 2020

Android Studio Java xml Learn free lessons in programming Android applications We will offer everything important for programming Android applications Follow us and subscribe with us

 بيئة تطوير أندرويد

جافا xml
تعلم دروسًا مجانية في برمجة تطبيقات Android
سنقدم كل شيء مهم لبرمجة تطبيقات Android
تابعنا واشترك معنا






 اندرويد استديو 
جافا 
تعلم دروس مجانيه في برمجه تطبيقات الاندرويد 
جميع ماهو مهم برمجه تطيبقات الاندرويد 
تابعنا واشترك معانا 

ProgressBar

 


package com.example.progressbar;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;

public class ProgressBarnew extends View {
private int sizeskbar=100;
public ProgressBarnew(Context context) {

super(context);

}

public ProgressBarnew(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ProgressBarnew(Context context, @Nullable AttributeSet attrs, int defStyleAttr){
super(context,attrs,defStyleAttr);
}

@Override
protected void onDraw(Canvas canvas) {
Paint p =new Paint(Paint.LINEAR_TEXT_FLAG);
p.setColor(Color.RED);
p.setTextSize(36.f);

//canvas.drawText("omar",0,100,0,0,p);
//p.setFontFeatureSettings();
// Bitmap bitmap=Bitmap.createBitmap(100,100,Bitmap.Config.ARGB_8888);
int wright=1000;//يمين
int left=10;//شمال
int up=100;//فوق
int down=200;//تحت

canvas.drawText("10%",left,up,p);
canvas.drawLine(left, up, wright, up, p);
canvas.drawLine(left, down, wright, down, p);
canvas.drawLine(left, up, left, down, p);
canvas.drawLine(wright, up, wright, down, p);
int xn=1;
for(int i=left;i<wright;i++){
xn++;
if(xn>sizeskbar) {
p.setColor(Color.RED);
canvas.drawLine(i, up, i, down, p);
} else {
p.setColor(Color.BLUE);
canvas.drawLine(i,up,i,down, p);
}
}
// canvas.drawPoint(i, iy, p);




//canvas.drawLine(0,0,500,10,p);

super.onDraw(canvas);
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent ev) {
int time=1;
//scrollBy((int) ev.getX(), (int) ev.getY());
this.getParent().requestDisallowInterceptTouchEvent(true);
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:

setPressed(true);

break;
case MotionEvent.ACTION_MOVE:
setPressed(true);
Log.d("tieme=","t"+ev.getEventTime());
Log.d("on=","t"+ev.getDownTime());
sizeskbar++;
if(ev.getEventTime()>ev.getDownTime()+500) {

if (ev.getX() > (getWidth() / 2)) {

scrollTo(getScrollX() + 50, getScrollY());
} else {

scrollTo(getScrollX() - 50, getScrollY());
}
}

//scrollTo((int) ev.getX(), getScrollY());
break;
case MotionEvent.ACTION_UP:
invalidate();
this.getParent().requestDisallowInterceptTouchEvent(false);
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
this.getParent().requestDisallowInterceptTouchEvent(false);
setPressed(false);
break;
}

return true;
}

}


MediaPlayer



package com.example.mediaplayer;



import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.ActionBarOverlayLayout;

import android.animation.TimeAnimator;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.media.Image;
import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaMetadata;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.media.MediaTimestamp;
import android.media.TimedMetaData;
import android.media.TimedText;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
import android.view.DisplayCutout;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import java.io.IOException;
import java.security.Permission;
import java.util.Locale;
import java.util.Map;

public class MainActivity extends AppCompatActivity {
private Uri myvidou_uri=null;

private static final int PICk_vidoreust=1001;
private MediaPlayer mediaPlayer1;
private TimeAnimator mTimeAnimator = new TimeAnimator();
private boolean isplay=false;
private LinearLayout linearLayout1;
//private final int maxmidaplyer=0;


@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);




SurfaceView surfaceView1=(SurfaceView)findViewById(R.id.surfaceView2);
final TextView textView1=(TextView)findViewById(R.id.textView2);



surfaceView1.getHolder().addCallback(new SurfaceHolder.Callback() {
@SuppressLint("SetTextI18n")
@Override
public void surfaceCreated(SurfaceHolder holder) {
if(myvidou_uri!=null){
String string1="";
MediaMetadataRetriever mediaMetadataRetriever1 =new MediaMetadataRetriever();
mediaMetadataRetriever1.setDataSource(getApplicationContext(), Uri.parse(myvidou_uri.toString()));


mediaPlayer1=MediaPlayer.create(getApplicationContext(),myvidou_uri);


mediaPlayer1.setDisplay(holder);





textView1.setText("info\n");




String infoplayrr="METADATA_KEY_ALBUM"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_ALBUMARTIST"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_ARTIST"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_AUTHOR"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_AUTHOR)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_BITRATE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE)+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_CAPTURE_FRAMERATE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE).toString()+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_CD_TRACK_NUMBER"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_COMPILATION"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COMPILATION)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_COMPOSER"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COMPOSER)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_DATE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_DISC_NUMBER"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_DURATION"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_EXIF_LENGTH"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_EXIF_LENGTH).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_EXIF_OFFSET"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_EXIF_OFFSET).toString()+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_GENRE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_HAS_AUDIO"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_AUDIO)+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_HAS_IMAGE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_IMAGE).toString()+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_HAS_VIDEO"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_IMAGE_COUNT"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_IMAGE_COUNT).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_IMAGE_HEIGHT"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_IMAGE_HEIGHT).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_IMAGE_PRIMARY"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_IMAGE_PRIMARY).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_IMAGE_ROTATION"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_IMAGE_ROTATION).toString()+"\n";
//infoplayrr=infoplayrr+"METADATA_KEY_IMAGE_WIDTH"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_IMAGE_WIDTH).toString()+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_TITLE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_MIMETYPE"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_MIMETYPE)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_NUM_TRACKS"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_NUM_TRACKS)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_LOCATION"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_LOCATION)+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_VIDEO_FRAME_COUNT"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_FRAME_COUNT).toString()+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_VIDEO_HEIGHT"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)+"\n";
// infoplayrr=infoplayrr+"METADATA_KEY_VIDEO_ROTATION"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION).toString()+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_VIDEO_WIDTH"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_WRITER"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_WRITER)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_YEAR"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR)+"\n";
infoplayrr=infoplayrr+"METADATA_KEY_HAS_VIDEO"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO)+"\n";

infoplayrr=infoplayrr+"METADATA_KEY_HAS_AUDIO"+"="+mediaMetadataRetriever1.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_AUDIO)+"\n";

textView1.setText(textView1.getText()+infoplayrr);

mediaPlayer1.start();
isplay=true;


}
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {

}
});



}
public void playvido(View view){
// mediaPlayer1.start();

}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==PICk_vidoreust && resultCode==RESULT_OK){
assert data != null;
myvidou_uri=data.getData();
}
}
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public void mediaretverar(View view){
Intent pickvido=new Intent(Intent.ACTION_PICK);
pickvido.setTypeAndNormalize("Video/*");
startActivityForResult(pickvido,PICk_vidoreust);




}

}


---------------------------------------------manifest--------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mediaplayer">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:ignore="ProtectedPermissions"/>


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
-----------------------------------------------------------------------------------------------------

----------------------------------------------layout-------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<ScrollView android:layout_alignParentStart="true" tools:context=".MainActivity" android:layout_alignParentLeft="true" android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/main_layout2" xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">


<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical">


<HorizontalScrollView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/HorizontalScrollView1" android:verticalScrollbarPosition="right" android:scrollbars="horizontal|none" android:requiresFadingEdge="horizontal" android:layout_gravity="clip_horizontal|center|center_horizontal|center_vertical|fill_vertical|end">


<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:orientation="horizontal">

<Button
android:id="@+id/button13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="mediaretverar"
android:text="add_play" />

</LinearLayout>

</HorizontalScrollView>


-<HorizontalScrollView android:layout_height="match_parent" android:layout_width="match_parent">


-<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:orientation="horizontal">

<SurfaceView android:layout_height="357dp" android:layout_width="437dp" android:id="@+id/surfaceView2" android:layout_weight="1"/>

</LinearLayout>

</HorizontalScrollView>


-


-

<HorizontalScrollView android:layout_height="match_parent" android:layout_width="match_parent">


-<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:orientation="horizontal">

<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView2" android:text="TextView" android:layout_weight="1"/>

</LinearLayout>

</HorizontalScrollView>


-


-


-

</LinearLayout>

</ScrollView>
-------------------------------------------------------------------------------------------------------




 

How to design an Android program

1إطلاق المشروع


تعريف الاهداف


مثال البرنامج يخدم الطلاب أو المدرسين من ناحيه كذا او كذا او يخدم البنوك


وضع خطه شامله للمشروع البرمجي


2التخطيط


تطوير خطه اداره المشروع البرمجي


تخطيط النطاق


حدود المشروع على المستوى العربي أو إقليمي أو دولي


تخطيط الوقت


تقدير مده المشروع البرمجي من البدايه حتى النهايه


يعني مشروع هذا يكلف أربعين يوم عدد ايام التخطيط والتنفيذ والمراقبه وآلانهاء


تقسيم المهام على الأدوار


من يوم كذا إلى كذا آبرهيم عليه إنجاز المهمه واذا تأخر على المدير حل هذا المشكله لتفادي التأخر


تخطيط الكلفه


تقدير الكلفه

وضع ميزانيه للكلفه 


تخطيط الجوده


هل البرنامج يطابق معيار الكفاءة وهل يشتغل بدون اي ضرر للجهاز يلعب بالذاكرة....   أو ضرر للمستخدم مراقبه الخصوصيه أو اختراقات واشياء أخرى 


تخطيط الموارد البشرية

تقسيم البرنامج إلى وحدات  حيث كل وحده على شخص ماء

مثال

احمد عليه تطوير حزم أو كود قواعد البيانات ابرهيم  عليه الايقونات والصور والثيمات 


وسيم عليه برمجه ثلاثيه الابعاد ....


تخطيط التواصل

استخدام البريد أو الورق للتواصل بين الفريق والاداره العليا أو المدير


تخطيط المخاطر

عمل خطه احتمال ماذا لو حدث كذا وكذا ما العمل


تخطيط المشتريات


عمل العقود البيع والشراء والتسويق للبرنامج وللمبرجين الذين يعملون عندك وللبيع داخل البرنامج... 


3 التنفيذ 


تنفيذ ما في الخطط


4 المراقبه والضبط


مراقبه سير الأمور وضبط الجوده حسب المعيار


5 الانهاء


اكتمل المشروع البرمجي ويجب رفعه إلى السوق


6 التطوير والتحديث

ملاحظه تكون خارج المده الزمنيه له حسابات اخرى



Login form

 


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loginfrom">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".login_ok">
</activity>
</application>

</manifest>
----------------------------------------------------------------------------------
package com.example.loginfrom;

import androidx.annotation.NonNull;

public class index_user {
private int index=0;
private int indexnow=0;

public void setIndex(int index) {
this.index = index;
}

public int getIndex() {
return index;
}

public void setIndexnow(int indexnow) {
this.indexnow = indexnow;
}

public int getIndexnow() {
return indexnow;
}
}
-----------------------------------------------------------------------------------------
package com.example.loginfrom;

public interface interfacelogin {
public useristrulogin[] userall=new useristrulogin[10];

public index_user index_user=new index_user();


public useristrulogin[] getUser();
public index_user getIndex_user();

}
---------------------------------------------------------------------------------------
package com.example.loginfrom;

import android.os.Bundle;
import android.view.ActionMode;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class login_ok extends AppCompatActivity implements interfacelogin{
TextView textView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
textView=(TextView)findViewById(R.id.textView);
String xstring="userindex="+Integer.toString(getIndex_user().getIndexnow())+"\n";
xstring+=("getUser="+getUser()[getIndex_user().getIndexnow()].getUser()+"\n");
xstring+=("getPasswrd="+getUser()[getIndex_user().getIndexnow()].getPasswrd()+"\n");
xstring+=("getCountlogin="+Integer.toString(getUser()[getIndex_user().getIndexnow()].getCountlogin())+"\n");
xstring+=("getCountLogoff="+Integer.toString(getUser()[getIndex_user().getIndexnow()].getCountLogoff())+"\n");
xstring+=("getIslogin="+Boolean.toString(getUser()[getIndex_user().getIndexnow()].getIslogin())+"\n");

textView.setText(xstring);

}
public void Logoff(View view){

finish();
}

@Override
public void onActionModeFinished(ActionMode mode) {

super.onActionModeFinished(mode);
}

@Override
protected void onResume() {
getUser()[getIndex_user().getIndexnow()].setCountLogoff(getUser()[getIndex_user().getIndexnow()].getCountLogoff()+1);
super.onResume();
}

@Override
public com.example.loginfrom.index_user getIndex_user() {
return index_user;
}

@Override
public useristrulogin[] getUser() {
return userall;
}
}
--------------------------------------------------------------------------------------
package com.example.loginfrom;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements interfacelogin {
private String username[]={"admin","root","user"};
private String password[]={"admin","root","123"};
private EditText input_username;
private EditText input_userpasseword;
private Context context;
private Toast toast1,toast2,toast3,toast4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
input_username=(EditText)findViewById(R.id.username);
input_userpasseword=(EditText)findViewById(R.id.password);

toast1=Toast.makeText(this,"اسم المستخدم وكلمه السر غير صحيح",Toast.LENGTH_SHORT);
toast2=Toast.makeText(this,"الرجاء ادخال اسم المستخدم",Toast.LENGTH_SHORT);
toast3=Toast.makeText(this,"الرجاء ادخال كلمه السر",Toast.LENGTH_SHORT);
toast4=Toast.makeText(this,"مرحبا",Toast.LENGTH_SHORT);
for(int i=0;i<getUser().length;i++){
getUser()[i]=new useristrulogin();
}

}

@Override
public useristrulogin[] getUser() {
return userall;
}
private void startlogin() {
Intent intent = new Intent(this, login_ok.class);

startActivity(intent);
}

@Override
public com.example.loginfrom.index_user getIndex_user() {
return index_user;
}

public void login(View view){
Boolean istrulogin=false;
if(input_username.getText().length()<1){
toast2.show();
}else {
if(input_userpasseword.getText().length()<1){
toast3.show();
}else {
for (int i = 0; i < username.length; i++) {

if (username[i].equals(input_username.getText().toString()) & password[i].equals(input_userpasseword.getText().toString())) {
//login is tru;
istrulogin = true;
toast4.show();
boolean is_fonud_sesshion=false;
for(int ix=0;ix<getUser().length;ix++){
if(getUser()[ix].getUser().equals(username[i])){

getUser()[ix].setPasswrd(password[i]);
getUser()[ix].setUser(username[i]);
getUser()[ix].setCountlogin(getUser()[ix].getCountlogin()+1);
getUser()[ix].setIslogin(true);
is_fonud_sesshion=true;
getIndex_user().setIndex(ix+1);
getIndex_user().setIndexnow(ix);

}



}

if(!is_fonud_sesshion){
getUser()[getIndex_user().getIndex()].setPasswrd(password[i]);
getUser()[getIndex_user().getIndex()].setUser(username[i]);
getUser()[getIndex_user().getIndex()].setCountlogin(getUser()[getIndex_user().getIndex()].getCountlogin()+1);
getUser()[getIndex_user().getIndex()].setIslogin(true);
is_fonud_sesshion=true;
getIndex_user().setIndexnow(getIndex_user().getIndex());
getIndex_user().setIndex(getIndex_user().getIndex()+1);


}


startlogin();
//finish();


}
}
if (!istrulogin) {


toast1.show();
}}

}

}



}
-------------------------------------------------------------------------------------------
package com.example.loginfrom;

public class useristrulogin {
private String user="";
private String passwrd="";
private Boolean islogin=false;
private int countlogin=0;
private int countLogoff=0;

public int getCountlogin() {
return countlogin;
}

public int getCountLogoff() {
return countLogoff;
}

public void setCountlogin(int countlogin) {
this.countlogin = countlogin;
}

public void setCountLogoff(int countsingup) {
this.countLogoff = countsingup;
}

public String getPasswrd() {
return passwrd;
}

public Boolean getIslogin() {
return islogin;
}

public void setIslogin(Boolean islogin) {
this.islogin = islogin;
}

public void setPasswrd(String passwrd) {
this.passwrd = passwrd;
}

public void setUser(String user) {
this.user = user;
}

public String getUser() {
return user;
}

}
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:background="@color/colorPrimary"
tools:context=".MainActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="315dp"
android:layout_height="339dp"
android:layout_margin="10dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="16dp"
android:layout_marginRight="20dp"
android:background="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">

<Button
android:id="@+id/button"
android:layout_width="275dp"
android:layout_height="51dp"
android:onClick="login"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.89" />

<EditText
android:id="@+id/username"
android:layout_width="273dp"
android:layout_height="50dp"
android:ems="10"
android:hint="user name"
android:inputType="textEmailAddress"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:layout_constraintBottom_toBottomOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.443" />

<EditText
android:id="@+id/password"
android:layout_width="273dp"
android:layout_height="50dp"
android:ems="10"
android:hint="password"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.606" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="162dp"
android:layout_height="76dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.142"
app:srcCompat="@drawable/account" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold" />

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="Logoff"
android:text="Logoff" />
</LinearLayout>

</LinearLayout>
-------------------------------------------------------------------------------------



Android Studio Java xml Learn free lessons in programming Android applications We will offer everything important for programming Android applications Follow us and subscribe with us

  بيئة تطوير أندرويد جافا xml تعلم دروسًا مجانية في برمجة تطبيقات Android سنقدم كل شيء مهم لبرمجة تطبيقات Android تابعنا واشترك معنا اند...