在我的应用程序中,我想使用CustomAdapter类创建SpinnerList,为此我写了下面的代码但是当我点击微调器列表然后数组列表图像没有加载在spinner列表中,就像我的下面屏幕为什么这个问题来了?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Category:"
android:layout_marginBottom="5dp"/>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
public class MainActivity extends AppCompatActivity {
public static final String[] titles = new String[] { "Strawberry",
"Banana", "Orange", "Hello" };
public static final Integer[] images = { R.drawable.image1,
R.drawable.image2, R.drawable.image3, R.drawable.image4 };
Spinner spinner;
List<RowItem> rowItems;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
rowItems = new ArrayList<RowItem>();
for (int i = 0; i < titles.length; i++) …Run Code Online (Sandbox Code Playgroud) 我已经为我的项目启用了YouTube数据API和Google+ API,并更改了Auth.java中的Android API密钥,我也将我的播放列表信息输入了Constants.java中。但是我仍然收到此无用的错误:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. YouTube Data API has not been used in project 608941808256 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=608941808256 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com/apis/api/youtube/overview?project=608941808256"
}
],
"message": "Access Not Configured. YouTube Data API has not been used in project 608941808256 …Run Code Online (Sandbox Code Playgroud) 嗨,Angular 新手,我在获取 HTTP 模块中的 HTTP 状态代码时遇到问题,我可以使用response.status轻松获取响应代码,但是当我使用HttpClientModule 时,我无法获取 response.status,它显示找不到地位。
所以,我怎样才能得到使用response.statusHttpClient模块Angular 4&5。请帮忙。
@Injectable()
export class RestProvider {
private apiUrl = 'https://restcountries.eu/rest/v2/al';
constructor(public http: HttpClient) {
console.log('Hello RestProvider Provider');
}
getCountries(): Observable<{}> {
return this.http.get(this.apiUrl).pipe(
map(this.extractData),
catchError(this.handleError)
);
}
private extractData(res: Response) {
let body = res;
return body || { };
}
private handleError (error: Response | any) {
let errMsg: string;
if (error instanceof Response) {
const err = error || ''; …Run Code Online (Sandbox Code Playgroud) 当我滚动页面超过导航栏的高度时,我想更改导航栏的背景颜色。
为了实现这一点,我使用了下面的逻辑,但问题是在滚动导航栏背景颜色发生变化之前,文本颜色保持不变。
我在这里有什么错误?
示例代码:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css"
integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.1/css/all.css"
integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ" crossorigin="anonymous">
<link href="assets/custom.css" rel="stylesheet">
<title>Karvy InnoTech</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top scrolled">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="container">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-lg-auto">
<li class="nav-item active">
<a class="nav-link" href="#home">Home …Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 开发一个网络应用程序,我想包含 ngx-toastr 来向用户发送通知,但它没有按预期工作。当我触发吐司时什么也没有发生我的代码在下面请有人帮助我请我做错了什么
export class AppComponent {
constructor(
private toast: ToastrService,
) { }
test() {
this.toast.success("I'm a toast!", "Success!");
}
}
Run Code Online (Sandbox Code Playgroud)
https://stackblitz.com/edit/angular-wsfroy?file=src%2Fapp%2Fapp.component.ts
我正在寻找一种方法来查找数组的索引位置,我想将该值存储在String中但是我们怎么能这样做请帮助我一些
String[] planets = new String[] { "Mercury","Mercury", "Venus", "Earth", "Mars",
"Jupiter", "Saturn", "Uranus", "Neptune"};
String[] Ruppes = new String[] { "100", "200","1000", "300", "400",
"500", "600", "700", "800"};
Run Code Online (Sandbox Code Playgroud) 嗨我想保存和检索NSObject类使用NSUserDefaults我写下面的代码,但我得到如下的异常
由于未捕获的异常'
NSInvalidArgumentException' 终止应用程序,原因:'尝试为密钥DATA插入非属性列表对象'
为了节省: -
SavingBean*savingbean = [[SavingBean alloc]init];
[savingbean savingData:userName.text :passWord.text];
NSUserDefaults * defaults = [[NSUserDefaults alloc]init];
[defaults setObject:savingbean forKey:@"DATA"];
Run Code Online (Sandbox Code Playgroud)
检索: -
defaults = [[NSUserDefaults alloc]init];
savingbean = [defaults objectForKey:@"DATA"];
NSLog(@"Username is===>%@",savingbean.userName);
NSLog(@"Password is===>%@",savingbean.passWord);
Run Code Online (Sandbox Code Playgroud)
ModelClas: -
.h文件: -
#import <Foundation/Foundation.h>
@interface SavingBean : NSObject{
NSString *userName;
NSString *passWord;
}
@property(nonatomic, retain) NSString *userName;
@property(nonatomic, retain) NSString *passWord;
-(void)savingData :(NSString*)userName :(NSString*)password;
@end
Run Code Online (Sandbox Code Playgroud)
.m文件: -
#import "SavingBean.h"
@implementation SavingBean
@synthesize userName,passWord;
-(void)savingData :(NSString*)username :(NSString*)password{
userName …Run Code Online (Sandbox Code Playgroud) 我的 mat-table 工作正常,但是当按照官方 api 文档添加 mat-sort 时,它在 ngAfterViewInit 处失败,并显示以下消息
无法设置未定义 aq LeadsComponent.push../src/app/leads/leads.component.ts.LeadsComponent.ngAfterViewInit 的属性“排序”
已经有一篇关于 Mat-table Sorting Demo 的帖子并尝试了它们,但我仍然无法让它工作。
有人可以帮我解决这个问题吗?官方示例使用组件本身定义的“静态”MatTableDataSource,但是我正在从后端进行查询。
MatSortModule 已经导入到 app.module.ts 中,mat-sort-header 指令应用于列,并且 ngAfterViewInit 已经与官方示例中的完全相同......
export class LeadsComponent implements OnInit,AfterViewInit {
displayedColumns: string[] = ['name', 'leadStatus', 'mobile', 'email', 'actions'];
dataSource: MatTableDataSource<LeadsChildObject>;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
constructor(public dialog: MatDialog, private dashBoardService: LeadsService,
private toast: ToastrService) {
}
ngAfterViewInit() {
this.dataSource.sort = this.sort;
}
ngOnInit() {
this.dashboardService.getFeedback.subscribe(
res => {
this.leadlist= res;
this.dataSource = new MatTableDataSource(this.leadlist);
}
);
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Compressor第三方库来压缩捕获的图像大小,其工作正常,现在大小显示为 KB,但是当我将此图像转换为BASE64时,文件大小变为 6MB 或更大大小,显示我的代码如下,有人可以帮我吗?我这样做是为了解决这个问题
File file= new Compressor(this).compressToFile(f);
String base64File = getBase64StringFile(file);
// Converting File to Base64.encode String type using Method
public static String getBase64StringFile(File f) {
InputStream inputStream = null;
String encodedFile= "", lastVal;
try {
inputStream = new FileInputStream(f.getAbsolutePath());
byte[] buffer = new byte[10240];//specify the size to allow
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();
Base64OutputStream output64 = new Base64OutputStream(output, Base64.DEFAULT);
while ((bytesRead = inputStream.read(buffer)) != -1) {
output64.write(buffer, 0, bytesRead);
}
output64.close(); …Run Code Online (Sandbox Code Playgroud) 我是学习者,有谁知道如何获取由 Spring Boot 创建的 Hibernate Session Factory 的句柄?我看到了许多解决方案,并且我实现了下面的代码,但是当我点击服务时出现异常
org.hibernate.HibernateException: No CurrentSessionContext configured!
Run Code Online (Sandbox Code Playgroud)
spring.datasource.url= jdbc:mysql://localhost:3306/sakila
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
Run Code Online (Sandbox Code Playgroud)
@SpringBootApplication
public class SpringBootCurd1Application {
public static void main(String[] args) {
SpringApplication.run(SpringBootCurd1Application.class, args);
}
@Bean
public SessionFactory sessionFactory(HibernateEntityManagerFactory hemf) {
return hemf.getSessionFactory();
}
}
Run Code Online (Sandbox Code Playgroud)
@Repository
public class EmployeeDao {
@Autowired
SessionFactory sessionFactory;
/**
* getListOfStates
*
* @return
*/
public List<?> getListOfStates(int userId) {
String hql = "FROM states s WHERE " + "s.userid = :userId";
Session session = sessionFactory.getCurrentSession(); …Run Code Online (Sandbox Code Playgroud)