Simple Spinner array not showing up - arrays

I try to make a simple spinner with 4 values,
but when i start to code the line and i reach R.array.XXXXX the text array becomes red and its dont resolve
package com.example.magazijnapp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.MenuPopupWindow;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import java.lang.reflect.Array;
public class MainActivity extends AppCompatActivity {
Spinner spinnermagazijn;
Button knop;
String[] magazijnarray;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinnermagazijn = findViewById(R.id.spinnermagazijn);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.
}
}
At the end of the line u see my problem.

You can do something like this:
Create the array with the hardcoded values in Strings.xml
<string-array name="my_array">
<item>Option 1</item>
<item>Option 2</item>
<item>Option 3</item>
<item>Option 4</item>
</string-array>
Now you add it as a property in your spinner, at MainActivity.xml
<Spinner
android:id="#+id/spinnermagazijn"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:spinnerMode="dropdown"
android:padding="8dp"
android:entries="#array/my_array"
android:textSize="15sp"/>
If I get you right, this is what you are looking for.

Related

How to update a property of an object/entity when a button click occurs in Springboot & React

I'm facing a problem which I cannot seem to resolve.
I have an entity which has a property (specifically a string) with a value of 'In magazijn':
package com.Code.Pakket.management.model;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.jpa.repository.Modifying;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
//Men maakt een JPA entity class zodat hibernate met onze data kan werken.
#Entity
public class Pakketje {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private int code;
private String status ="In magazijn";
public Pakketje() {
}
I would like this string to change when a button click occurs in the react application. The specific object from which the value should be changed is already existing inside of the database, and only the value "In magazijn" should be changed to "Onderweg". This value should change inside of the database.
I have tried the following inside of the service class:
#Override
public String StatusOnderweg(Pakketje pakketje) {
return pakketjeRepository.save(pakketje.setStatus("Onderweg"));
}
So "Pakketje pakketje" is the object of which the string should be changed. I thought about saving the specific object once more to the database (even tough the object already exists) and save it with another string.
My Repository:
package com.Code.Pakket.management.repository;
import com.Code.Pakket.management.model.Pakketje;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
//https://www.javadevjournal.com/spring-boot/spring-boot-with-hibernate/ -- Punt5.
#Repository
public interface PakketjeRepository extends JpaRepository<Pakketje,Integer> {
}
I just don't have an idea how to make this code with a repository, service and controller structure... Any advice?
Thanks in advance.

Both katalon and eclipse facing the issue while uploading a file on automation. Mentioned in detail below

package tools
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import java.awt.Robot
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.awt.event.KeyEvent
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
public class uploadFiles {
#Keyword
def uploadFile (TestObject to, String filePath) {
WebUI.click(to)
StringSelection ss = new StringSelection(filePath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.delay(1000); //Millisecond 1 second delay only if needed
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.delay(1000); //Millisecond 1 second delay only if needed
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
}
Above code is placed in keywords folder in the project structure.
CustomKeywords.'tools.uploadFiles.uploadFile'(iWay_Product.findElement(By.cssSelector('input#fuDrivers')).click(),'D:\\UserImport_Template.xls')
Thread.sleep(2500) //Millisecond 2.5 second delay only if needed
//More files can be added here...
This above code has been used in the actual test cases. Always getting this below error.
org.openqa.selenium.InvalidArgumentException: invalid argument

Error while updating 'end' in shadow node of type: BVLinearGradient

I get "Error while updating 'end' in shadow node of type: BVLinearGradient" error when i run my react native app and the error seems to emanate from my MainApplication.java file here is my code:
package com.*;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactPackage;
import com.horcrux.svg.SvgPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.NavigationApplication;
import com.wheelpicker.WheelPickerPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication {
#Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
// Add the packages you require here.
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new WheelPickerPackage(),
new VectorIconsPackage(),
new SvgPackage(),
new LinearGradientPackage()
);
}
}
Please help me resolve this
This is a bug with the react-native-linear-gradient. The issue is in open status. For the time being, there are 2 solutions-
Replace start with startPoint and end with endPoint props for <LinearGradient/>
Downgrade react-native version to 0.50.3
The details for this issue is below:
https://github.com/react-native-community/react-native-linear-gradient/issues/246

getLoaderManager: in an activity

I am writing an app for a WIMMOne watch: no orientation changes, a small simple screen, and Android version 7.
I got my first Android APP running, but based on a book, it had a fragment. But fragments added complications I do not want to deal with.
My second app has a similar structure: list of items then select an item to see or update details. So I am trying to just read a cursor, and create an array then call "setListAdapter(lstAdapter);".
I started with:
getLoaderManager().initLoader(0, null, this);
Got this error:
The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks) in the type LoaderManager
is not applicable for the arguments (int, null, PhoneListActivity)
So I tried their suggestion:
getLoaderManager().initLoader(0, null, (android.app.LoaderManager.LoaderCallbacks<D>) this);
Got this error:
The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks) from the type
LoaderManager refers to the missing type D
So I tried this:
getLoaderManager().initLoader(0, null, (android.app.LoaderManager.LoaderCallbacks) this);
and got this error:
Type safety: Unchecked invocation initLoader(int, null, LoaderManager.LoaderCallbacks)
of the generic method initLoader(int, Bundle, LoaderManager.LoaderCallbacks) of type LoaderManager
Several postings said to use this for version below 11
getSupportLoaderManager().initLoader(0, null, this);
but that gives me this error:
The method getSupportLoaderManager() is undefined for the type PhoneListActivity
I have also seen not to use "getLoaderManager: in an activity.
So what am I doing wrong?
or how do I just read from a cursor and create a list without creating complexities of a fragment?
Am I just missing an import?
Many thanks,
Clark
Below is what I currently have:
package com.wimmone.phonenos;
import android.view.Menu;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ListActivity;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.database.Cursor;
import android.net.Uri;
import android.app.Application;
import android.content.Intent;
import android.database.Cursor;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import android.os.Environment;
import com.wimm.framework.app.Dialog;
public class PhoneListActivity extends ListActivity
implements
LoaderCallbacks<Cursor>
{
private SimpleCursorAdapter mAdapter;
List strRecId = new ArrayList();
private ListAdapter lstAdapter;
String strPhoneGroup = "";
String strPhoneName = "";
String strPhoneHome = "";
String strPhoneCell = "";
String strPhoneWork = "";
private Button btn_Add;
List strRecord = new ArrayList(3);
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.phone_list_activity);
String[] strItems = new String[] {PhoneProvider.COLUMN_PHONE_NAME};
int[] iCnt = new int[] { R.id.text1 };
mAdapter = new SimpleCursorAdapter(this, R.layout.phone_row,
null, strItems, iCnt, 0);
Log.d("PHONENOS***", "X onCrt: x02 START");
setListAdapter(mAdapter);
//getLoaderManager().initLoader(0, null, this);
//getLoaderManager().initLoader(0, null, this);
getSupportLoaderManager().initLoader(0, null, this);
//-----------------------------------------------
// define add button
Button btnAdd = (Button) findViewById(R.id.btn_Add);
btnAdd.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
Log.d("PHONENOS***", "S create view btnAddEvent:");
}
} );
//-----------------------------------------------
// define Exit button
Button btnExit = (Button) findViewById(R.id.btn_Exit);
btnExit.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
Log.d("PHONENOS***", "S create view btnEXIT:");
//Toast.makeText(this, "Good bye",
//Toast.LENGTH_SHORT).show();
// Application.onTerminate();
finish();
}
} );
//-----------------------------------------------
// define EXPORT button
Button btnExport . . .
}
//===============================================================
// DATA BASE ROUTINES TO LOAD FROM CURSOR
#Override
public Loader<Cursor> onCreateLoader(int ignored, final Bundle args)
{
Log.d("EventLst","S LoadCSR");
return new CursorLoader(this, PhoneProvider.CONTENT_URI, null,
null, null, null);
// Log.d("PHONENOS***","X LoadCSR");
}
#Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor)
{
// Log.d("PHONENOS***","0 LoadFin");
int iRecNo = 0;
int RowNO = 0;
int iBuCnt = 0;
String strPath = "";
mAdapter.swapCursor(cursor);
strRecId.clear();
strRecord.clear();
strRecord.add(0, "mm-dd-yy: Event name");
cursor.moveToFirst();
Log.d("EventLst","1 LoadFin DO");
// Read from cursor and add to list
while (cursor.isAfterLast() == false)
{
iRecNo = iRecNo + 1;
// - Table has 4 columns, read them into string array: strC
String strC[] = { (cursor.getString(0)), (cursor.getString(1)),
(cursor.getString(2)), (cursor.getString(3)),
(cursor.getString(4)), (cursor.getString(5))
};
String strRowNo = (cursor.getString(0));
strPhoneGroup = (cursor.getString(1));
strPhoneName = (cursor.getString(2));
strPhoneHome = (cursor.getString(3));
strPhoneCell = (cursor.getString(4));
strPhoneWork = (cursor.getString(5));
Log.d("PHONENOS***","4 LoadCSR:" + "I:" + iRecNo + "=" + strRowNo + "N:" + strPhoneName);
// - Concatenate Group and name into one string, add to table
strRecord.add(iRecNo, strPhoneGroup + "/" + strPhoneName);
// - save record number for each event in strRecId
// - Records are sorted by date, so we need to save RowId to pass
// to edit screen
strRecId.add((cursor.getString(0)));
iBuCnt = iBuCnt + 1;
cursor.moveToNext();
} // --------------------end of while loop
//cursor.close();
lstAdapter = new ArrayAdapter<String>(this,
R.layout.phone_row, R.id.text1, strRecord);
// * Call to SetListAdapter()informs ListFragment how to fill ListView
// * here use ArrayAdapter
setListAdapter(lstAdapter);
// Log.d("EventLst","8 LoadCSR:" + "ALLDONE");
}
#Override
public void onLoaderReset(Loader<Cursor> loader)
// This is called when the last Cursor provided to onLoadFinished() above
// is about to be closed
{
// Log.d("EventLst","x LoadRst");
// INITRUN REMOVE BELOW
mAdapter.swapCursor(null);
}
}
Since no one answered, I re-did my program and got it working. I really needed to use "extends LauncherActivity" (for the WIMMOne). Since I am dealing with a small database on a smart watch, the loader isn't really needed anyway, so I just dropped the use of the loader and used the cursor directly. It actually seems faster.
You can let your acitvity extend FragmentActivity and use
getSupportLoaderManager().initLoader(0, null, this);
Hope this helps you!

JSF with google app engine. not sure how to call method in managedbean

I'm using google app engine with JSF. i want to call a function when user press that button:
<p:commandButton value="Ajax Submit" action="#{todo.test}" />
and I put todo under src->package test123.
package test123;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
#ManagedBean(name="todo")
#SessionScoped
public class Todo {
public void test(ActionEvent event){
System.out.println("lol");
}
}
but when i press button, error occurs:
sth like this:
javax.el.MethodNotFoundException: /Template/default.xhtml #39,38 action="#{todo.test}": Method not found: test.Todo#7929b073.test()
am i wrong? or do i need to do some configurations ?
Thanks
Use actionListener="#{todo.test}" or try:
public void test()
{
System.out.println("lol");
}
See here for more details: Differences between action and actionListener

Resources