Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

the android code is like this 

ublic class PlayerActivity2 extends AppCompatActivity {
   ListView simpleList;
   String SerialNo[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
   int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10};
   String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd", "eee jk", " ijk", "Virgil jk", "gil jklk"};
   String Score[] = {"1", "2", "3", "5", "4", "3", "5", "5", "5", "5"};

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity2);
       simpleList = (ListView) findViewById(R.id.simpleListView);

       CustomAdapter customAdapter = new CustomAdapter(getApplicationContext(), simpleList, SerialNo, flags, Names, Score);
       simpleList.setAdapter(customAdapter);

       simpleList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
           @Override
           public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
               ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
               if (imageView != null) {
                   saveImage(imageView, Names[position]);
               }
           }
       });
   } // add a closing brace here

   public void saveImage(View view, String name) {
       ImageView imageView = (ImageView) view;
       Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

       String fileName = name + ".jpg";
       File dir = getApplicationContext().getDir("images", Context.MODE_PRIVATE);
       File file = new File(dir, fileName);

       try {
           FileOutputStream fos = new FileOutputStream(file);
           bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
           fos.flush();
           fos.close();
           Toast.makeText(getApplicationContext(), "Image saved", Toast.LENGTH_SHORT).show();
       } catch (Exception e) {
           e.printStackTrace();
       }
   }

   public void showToast(View view) {
       Toast.makeText(getApplicationContext(), "Save Image button clicked", Toast.LENGTH_SHORT).show();
   }
}

 

-xml

<?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"
tools:context=".PlayerActivity2">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"

/>

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/icon"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:src="@drawable/image1" />


<TextView
android:id="@+id/textNamesView"
android:layout_width="382dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Razi 380"
android:textColor="@color/black" />

</com.google.android.material.appbar.AppBarLayout>


<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">

<ListView
android:id="@+id/simpleListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#BDB6B6"
android:dividerHeight="2dp"
tools:layout_conversion_absoluteHeight="1300dp"
tools:layout_conversion_absoluteWidth="411dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

<Button
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save Image"
android:onClick="showToast" />
<TextView
android:id="@+id/textNamesView"
android:layout_width="382dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Razi 380"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/saveButton" />

</androidx.constraintlayout.widget.ConstraintLayout>

how correct these errors ,make this code can run  please show me the code

Compilation errors
e saveButton <Button>: Missing Constraints in ConstraintLayout
ⒸsimpleListView <ListView>: Missing Constraints in ConstraintLayout
8 textNamesView <TextView>: Duplicate ids within a single layout
Ⓒ textNamesView <TextView>: Duplicate ids within a single layout
8 saveButton <Button>: Duplicate ids within a single layout
ⒸsaveButton <Button>: Duplicate ids within a single layout
8 textNamesView <TextView>: Invalid Constraints
A textNamesView <TextView>: Accessibility Issue
A saveButton <Button>: Duplicate speakable text present
expand button
Transcribed Image Text:Compilation errors e saveButton <Button>: Missing Constraints in ConstraintLayout ⒸsimpleListView <ListView>: Missing Constraints in ConstraintLayout 8 textNamesView <TextView>: Duplicate ids within a single layout Ⓒ textNamesView <TextView>: Duplicate ids within a single layout 8 saveButton <Button>: Duplicate ids within a single layout ⒸsaveButton <Button>: Duplicate ids within a single layout 8 textNamesView <TextView>: Invalid Constraints A textNamesView <TextView>: Accessibility Issue A saveButton <Button>: Duplicate speakable text present
CustomAdapter customAdapter = new CustomAdapter (getApplicationContext(), simpleList, SerialNo, flags, N
simpleList.setAdapter (customAdapter);
simpleList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick (AdapterView<?> adapterView, View view, int position, long id) {
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
if (imageView != null) {
}
}
save Image (imageView, Names [position]);
});
// add a closing brace here
expand button
Transcribed Image Text:CustomAdapter customAdapter = new CustomAdapter (getApplicationContext(), simpleList, SerialNo, flags, N simpleList.setAdapter (customAdapter); simpleList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick (AdapterView<?> adapterView, View view, int position, long id) { ImageView imageView = (ImageView) view.findViewById(R.id.imageView); if (imageView != null) { } } save Image (imageView, Names [position]); }); // add a closing brace here
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education