ERROR StatusLogger Error processing element BatchDelivery ([appenders: null]): CLASS_NOT_FOUND - log4j2

I was trying to send logs to elastic search but my log4j2 file shows this error. Can anyone help me out of this. Thanks in advance.
TestLogger.java
public class TestLogger {
private static final Logger logger = LogManager.getLogger(TestLogger.class);
public static void main(String[] args) {
logger.info("Hello World !");
logger.info("Hello ElasticSearch !");
}
}
log4j2.xml
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%-25c][%t] %m%n" />
</Console>
<BatchDelivery batchSize="10000" deliveryInterval="1000">
<NoSql name="elasticsearchAppender">
<Elasticsearch url="http://10.162.205.175:9200/_bulk" index="data_upload_assignment" type="log4j2">
</Elasticsearch>
</NoSql>
</BatchDelivery>
</Appenders>
<loggers>
<!-- <logger name="com.ait.TestLogger">
<appender-ref ref="elasticsearchAppender" />
</logger>-->
<root level="ALL">
<appender-ref ref="Console" />
<appender-ref ref="elasticsearchAppender" />
</root>
</loggers>

Related

Load URL from ImageView

I need to load a URL inside my app with the click of an ImageView. I get the app to load until I start trying to assign intents (on the MainActivity.java) to my ImageViews (on activity_main.xml).
I have tried ImageButton vs ImageView; and both come with their own set of issues I can't seem to find answers to. I finally gave up on the imageButton and am now trying my luck at ImageView. All Android components are up-to-date which includes the software itself, the gradle, and plugins.
activity_main.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"
android:background="#color/mainBackground"
tools:context=".MainActivity">
<ImageView
android:id="#+id/s"
android:layout_width="0dp"
android:layout_height="0dp"
android:clickable="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="16dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/y"
app:layout_constraintEnd_toStartOf="#+id/v"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/s"
tools:visibility="visible" />
<ImageView
android:id="#+id/v"
android:layout_width="0dp"
android:layout_height="0dp"
android:clickable="true"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/q"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/s"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/v"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.app.sega;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import java.net.URI;
import java.net.URL;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView img_s = (ImageView) findViewById(R.id.s);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://southeastgeorgiatoday.com"));
startActivity(intent);
}
});
ImageView img_v = (ImageView) findViewById(R.id.q);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://us7.maindigitalstream.com/2780/"));
startActivity(intent);
}
});
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.sega" >
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<data android:scheme="http" android:host="www.southeastgeorgiatoday.com" />
<data android:scheme="http" android:host="us7.maindigitalstream.com/2780/" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The objective is to open the url of the intent inside the app with the click of the referenced ImageView. But since including this intent script on the MainActivity.java it will not build, let alone install and launch. I have tried it both on the virtual and actual device via Android's Emulator and it will not install on either.
Here is the error message I get from the LogCat during the build process...
C:\Users\webwi\Documents\_MobileApps\SEGA\app\src\main\java\com\app\sega\MainActivity.java:23: error: cannot find symbol
img.setOnClickListener(new View.OnClickListener() {
^
symbol: variable img
location: class MainActivity
C:\Users\webwi\Documents\_MobileApps\SEGA\app\src\main\java\com\app\sega\MainActivity.java:33: error: cannot find symbol
img.setOnClickListener(new View.OnClickListener() {
^
symbol: variable img
location: class MainActivity
2 errors
Also, it might be worth mentioning in both of the intent lines that begin with "img.setOnClickListener..." the 'img' before the '.' is red.
Obviously there is something wrong with my intents, I'm just not sure what? Any advice.

OData Model Not Working

I am trying to use expand option in my XML view but it's resulting no data.
Data are coming from backend as I can see in debugging under 'Network' option but there seems to be some binding issue in XML view.
Component.js
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"sem/stock_app/model/models"
], function(UIComponent, Device, models) {
"use strict";
return UIComponent.extend("sem.stock_app.Component", {
metadata: {
manifest: "json"
},
/**
* The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
* #public
* #override
*/
init: function() {
var url = "/sap/opu/odata/sap/ZMATLIST_SRV_02";
var odata = new sap.ui.model.odata.ODataModel(url, {
json: true
});
this.setModel(odata);
UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
this.setModel(models.createDeviceModel(), "device");
}
});
});
manifest.json
{
"_version": "1.7.0",
"sap.app": {
"id": "sem.stock_app",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"sourceTemplate": {
"id": "ui5template.basicSAPUI5ApplicationProject",
"version": "1.40.12"
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": [
"sap_hcb",
"sap_belize"
]
},
"sap.ui5": {
"rootView": {
"viewName": "sem.stock_app.view.mat",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.core": {},
"sap.m": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "sem.stock_app.i18n.i18n"
}
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "sem.stock_app.view",
"controlId": "idAppControl",
"controlAggregation": "pages"
},
"routes": [{
"name": "r1",
"pattern": "",
"target": "t1"
},
{
"name": "r2",
"pattern": "page2/{noti}",
"target": "t2"
}],
"targets": {
"t1": {
"viewName": "mat",
"viewId": "idmat",
"controlAggregation": "pages",
"viewLevel": 1
},
"t2": {
"viewName": "table",
"viewId": "idtable",
"controlAggregation": "pages",
"viewLevel": 2
}
}
}
}
}
Root View
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:core="sap.ui.core"
controllerName="sem.stock_app.controller.mat"
displayBlock="true"
>
<App id="idAppControl">
<Page title="Material Input">
<Label text="Material Selection"/>
<Input id="materialInput"
type="Text"
width="50%"
placeholder="Enter Material"
showSuggestion="true"
showValueHelp="false"
valueHelpRequest="handleValueHelp"
submit="onSubmit"
suggestionItems="{/matlistSet}"
>
<suggestionItems>
<core:Item text="{Matid}"/>
</suggestionItems>
</Input>
<Button text="Get Details" enabled="true" press="myPress"/>
</Page>
</App>
</mvc:View>
Table View
<mvc:View
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
controllerName="sem.stock_app.controller.table"
>
<App id="tableApp">
<Page
title="Table"
showNavButton="true"
navButtonPress="onNavBack"
>
<Table
growing="true"
items="{
path: 'odata>/matlistSet',
parameters: {
expand: 'NP_ON_MATID'
}
}"
itemPress="onListItemPressed"
width="100%"
mode="MultiSelect"
>
<columns>
<Column>
<Text text="Material ID"/>
</Column>
<Column>
<Text text="Category"/>
</Column>
<Column>
<Text text="Material Desc"/>
</Column>
<Column>
<Text text="Plant"/>
</Column>
</columns>
<items>
<ColumnListItem type="Active">
<Text text="{odata>NP_ON_MATID/Matid}"/>
<Text text="{odata>NP_ON_MATID/Category}"/>
<Text text="{odata>NP_ON_MATID/Matdesc}"/>
<Text text="{odata>NP_ON_MATID/Plant}"/>
</ColumnListItem>
</items>
</Table>
</Page>
</App>
</mvc:View>
Table Controller
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/core/routing/History"
], function(Controller, History) {
"use strict";
return Controller.extend("sem.stock_app.controller.table", {
onInit: function() {this.getOwnerComponent().getRouter().getRoute("r2").attachPatternMatched(this.mynav, this);
this.getOwnerComponent().getRouter().setView("table");
},
mynav: function(oeve) {
var data = oeve.getParameters().arguments.noti;
var params = "('" + data + "')?$expand=NP_ON_MATID";
var path = "/matlistSet" + params + "";
this.getView().bindElement(path);
},
onNavBack: function(window) {
var oHistory = History.getInstance();
var sPreviousHash = oHistory.getPreviousHash();
if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("overview", {}, true);
}
},
});
});
metadata.xml
<?xml version="1.0" encoding="utf-8" ?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema Namespace="ZMATLIST_SRV_02" xml:lang="en" sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="matlist" sap:content-version="1">
<Key>
<PropertyRef Name="Matid" />
</Key>
<Property Name="Matid" Type="Edm.String" Nullable="false" MaxLength="18" sap:unicode="false" sap:label="Material" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Category" Type="Edm.String" Nullable="false" MaxLength="20" sap:unicode="false" sap:label="Char20" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Matdesc" Type="Edm.String" Nullable="false" MaxLength="40" sap:unicode="false" sap:label="Char" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Plant" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Plant" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Status" Type="Edm.String" Nullable="false" MaxLength="20" sap:unicode="false" sap:label="Char20" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Qty" Type="Edm.Decimal" Nullable="false" Precision="13" Scale="3" sap:unicode="false" sap:label="Quantity" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<NavigationProperty Name="NP_ON_MATID" Relationship="ZMATLIST_SRV_02.MATASSOCIATION" FromRole="FromRole_MATASSOCIATION" ToRole="ToRole_MATASSOCIATION" />
</EntityType>
<EntityType Name="matdetails" sap:content-version="1">
<Key>
<PropertyRef Name="Matid" />
</Key>
<Property Name="Matid" Type="Edm.String" Nullable="false" MaxLength="18" sap:unicode="false" sap:label="Material" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Matitno" Type="Edm.Int32" Nullable="false" sap:unicode="false" sap:label="Number" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Category" Type="Edm.String" Nullable="false" MaxLength="20" sap:unicode="false" sap:label="Char20" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Matdesc" Type="Edm.String" Nullable="false" MaxLength="40" sap:unicode="false" sap:label="Char" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
<Property Name="Plant" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Plant" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />
</EntityType>
<Association Name="MATASSOCIATION" sap:content-version="1">
<End Type="ZMATLIST_SRV_02.matlist" Multiplicity="1" Role="FromRole_MATASSOCIATION" />
<End Type="ZMATLIST_SRV_02.matdetails" Multiplicity="*" Role="ToRole_MATASSOCIATION" />
<ReferentialConstraint>
<Principal Role="FromRole_MATASSOCIATION">
<PropertyRef Name="Matid" />
</Principal>
<Dependent Role="ToRole_MATASSOCIATION">
<PropertyRef Name="Matid" />
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="ZMATLIST_SRV_02_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
<EntitySet Name="matlistSet" EntityType="ZMATLIST_SRV_02.matlist" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:content-version="1" />
<EntitySet Name="matdetailsSet" EntityType="ZMATLIST_SRV_02.matdetails" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:content-version="1" />
<AssociationSet Name="MATASSOCIATIONSet" Association="ZMATLIST_SRV_02.MATASSOCIATION" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1">
<End EntitySet="matlistSet" Role="FromRole_MATASSOCIATION" />
<End EntitySet="matdetailsSet" Role="ToRole_MATASSOCIATION" />
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Issues to fix
Backend
According to your service metadata, the foreign key inside matdetails is also the only primary key at the same time. I.e. the Matids in matdetails cannot be unique if one matlist is supposed be associated with multiple matdetails entities.
→ Make sure that primary keys (or them combined) are all unique in the entire entity set.
According to your screenshot, the response body of your entity set doesn't contain the property "results" which is not OData V2 compliant (Same as this issue. See also difference between OData V1 and OData V2). The "response" property needs to be there in each collection so that UI5 can display the items correctly.
→ Make sure that the response body is OData V2 compliant.
Frontend
Model
There was no model name passed when calling setModel.
→ Either pass the model name according to your view: this.setModel(odata, "odata")
→ Or remove the model name from everywhere. E.g.: <Text text="{Matid}"/>
Also worth reading: Stop Using sap.ui.model.odata.ODataModel!
UI
The root view and its controller are instantiating twice. In order to avoid that, please read:
→ Why is my Main Controller being called twice?
→ Discussion in https://github.com/SAP/openui5/issues/1746
The application contains <App> multiple times. A typical UI5 application should contain only a single root element. If not, you might end up having this kind of problems.
→ Remove all the <App> from views except from the root view.
Since you want to display matdetails entities of selected matlist entity in the table, binding items there with the absolute path /matlistSet doesn't make sense.
→ Replace ...
items="{
path: 'odata>/matlistSet',
parameters: {
expand: 'NP_ON_MATID'
}
}
... with items="{ path: 'odata>NP_ON_MATID', templateShareable: false }". This binding is now relative. The navigation property NP_ON_MATID will be resolved once the selected context is given in the controller. See also Binding Path from the documentation.
Controller
On patternMatched, the selected Matid value is given. So far so good but there are two anti-patterns in the following lines:
var params = "('" + data + "')?$expand=NP_ON_MATID";
var path = "/matlistSet" + params + "";
→ Avoid creating entity key(s) manually.
→ Avoid appending ?$expand manually as it won't expand the entity. Pass the navigation property to the parameters/expand of bindElement/bindObject instead.
Off-topic but if you want to navigate back: Remove window parameter from onNavBack: function(window) { ... }. Otherwise, the window in window.history.go is not the global window object but the press event from the back button.

Custom ionic/cordva plugin for iOS. Method not defined in plugin error

I am writing my custom plugin in ionic for iOS in swift but I get the following error:
ERROR: Method 'initialize:' not defined in Plugin 'RabbitMqPlugin'
I have searched in order to find solution but I could not figure out what is the problem.
Below is my code.
plugin.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-rabbitmq"
version="0.0.1">
<name>RabbitMqPlugin</name>
<js-module src="www/plugin.js" name="RabbitMqPlugin">
<clobbers target="RabbitMqPlugin" />
</js-module>
<!-- ios -->
<dependency id="cordova-plugin-cocoapod-support" />
<dependency id="cordova-plugin-add-swift-support" />
<platform name="ios">
<pods-config ios-min-version="9.0" use-frameworks="true">
</pods-config>
<pod name="RMQClient" />
<config-file target="config.xml" parent="/*">
<feature name="RabbitMqPlugin">
<param name="ios-package" value="CDVDevice"/>
</feature>
</config-file>
<source-file src="src/ios/CDVHttpRequest.swift" />
<source-file src="src/ios/CDVRabbitMq.swift" />
<source-file src="src/ios/CDVRabbitMqPlugin.swift" />
</platform>
</plugin>
plugin.js file in www folder:
var exec = require('cordova/exec');
var PLUGIN_NAME = 'RabbitMqPlugin';
var RabbitMqPlugin = {
initialize: function(phrase, cb) {
exec(cb, null, PLUGIN_NAME, 'initialize', [phrase]);
}
};
module.exports = RabbitMqPlugin;
CDVRabbitMqPlugin.swift file in src/ios folder:
import Foundation
#objc(RabbitMqPlugin) class RabbitMqPlugin : CDVPlugin {
var mRabbit:rabbitMQ!;
#objc(initialize:)
func initialize(_ command: CDVInvokedUrlCommand){
var pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR
);
let token = command.arguments[0] as! String;
if (token.characters.count > 0) {
mRabbit = rabbitMQ(mToken: token);
pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR
);
}
self.commandDelegate!.send(
pluginResult,
callbackId: command.callbackId
)
}
}
I have installed the cordova-plugin-add-swift-support module in order to support swift.
I have added custom plugin ionic plugin for Android and I implemented to my ionic project successfully.
Hope you can help me. Thank you
Your feature in the plugin.xml is wrong, it should be
<feature name="RabbitMqPlugin">
<param name="ios-package" value="RabbitMqPlugin"/>
</feature>
Also, if you are not naming the classes with CDVClassname, don't name the files that contain those classes starting with CDV, not sure if that will fail in Swift, but better name the Swift files with the same name the class they contain

English font working but non-English (Hindi) font not displaying in webview

An English font is working in HTML in webview, but the non-English font (Hindi) is not displaying in HTML in webview.
Here is my source code.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.wptrafficanalyzer.webviewcustomfont"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="in.wptrafficanalyzer.webviewcustomfont.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
demo.html
<html>
<head>
<meta http-equiv="content-type" content="text/html;" charset="UTF-8">
<style>
/** Specify a font named "MyFont",
and specify the URL where it can be found: */
#font-face {
font-family: "MyFont";
src: url('file:///android_asset/fonts/BLKCHCRY.TTF');
}
h2 { font-family:"MyFont"}
#font-face {
font-family: "MyFontSD";
src: url('file:///android_asset/fonts/SHREE-DEV7-1076H.TTF');
}
h1 { font-family:"MyFontSD"}
</style>
</head>
<body>
<h2>
Welcome to BLACK CHANCERY FONT
</h2>
<h1>
1234567890
Am{X
</h1>
</body>
</html>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/hello_world" />
</RelativeLayout>
MainActivity.java
package in.wptrafficanalyzer.webviewcustomfont;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView mWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Getting reference to WebView of the activity_main layout
mWebView = (WebView) findViewById(R.id.webview);
// Loading an HTML page into webview
mWebView.loadUrl("file:///android_asset/demo.html");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Note:
HTML file demo.html is copied in the assets folder
BLKCHCRY.TTF font file is copied in fonts folder
SHREE-DEV7-1076H.TTF font file is copied in fonts folder
Link to download fonts (SHREE-DEV7-1076H.TTF and BLKCHCRY.TTF)

button onclick event dont work in xamarin

i have problem with my code. i have created button "sign up", i want when i click on that button a dialog called "dialog_signup appear.
The problem is it doesnt appear. and i always get this error so far
**2>A numeric comparison was attempted on "$(_DeviceSdkVersion)" that evaluates to "" instead of a number, in condition "$(_DeviceSdkVersion) >= 21".
2>Build FAILED.
2>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========**
Here is my code
MainActivity.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Content.Res;
namespace GameLandPlus
{
[Activity(Label = "GameLandPlus", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
private Button mbtnSignup;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
mbtnSignup = FindViewById<Button>(Resource.Id.btnsignup);
mbtnSignup.Click += (object sender, EventArgs args) =>
{
FragmentTransaction transaction = FragmentManager.BeginTransaction();
dialog_signup signupDialog = new dialog_signup();
signupDialog.Show(transaction, "dialog fragment");
};
}
}
}
-->
main.axml
<?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="fill_parent"
android:background="#android:color/background_light"
android:weightSum="100"
android:minWidth="25px"
android:minHeight="25px">
<ImageView
android:src="#drawable/images"
android:layout_width="match_parent"
android:layout_weight="20"
android:layout_height="0dp"
android:id="#+id/imageView1" />
<TextView
android:text="Create Account"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_weight="20"
android:layout_height="0dp"
android:textColor="#000000"
android:id="#+id/createaccount"
android:textSize="35sp"
android:gravity="center"
android:textStyle="bold" />
<Button
android:layout_width="match_parent"
android:layout_weight="10"
android:layout_height="0dp"
android:gravity="center"
android:id="#+id/signin"
android:textColor="#FFFFFF"
android:background="#drawable/butto1"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:text="Sign in"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="5" />
<TextView
android:text="or"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_weight="15"
android:layout_height="0dp"
android:id="#+id/or"
android:textColor="#000000"
android:textSize="35sp"
android:gravity="center"
android:textStyle="bold" />
<Button
android:text="Sign Up"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:id="#+id/btnsignup"
android:textColor="#FFFFFF"
android:background="#drawable/butto1"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:shadowColor="#00ffffff"
android:shadowRadius="5"
android:drawableRight="#drawable/goodmess" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="35"
android:minHeight="15px"
android:minWidth="15px">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBar1"
android:background="#drawable/progressbar"
android:indeterminate="true"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>
-->
the dialog page i want to pop up when i click on the button
dialogSignup.axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#F1F3F4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="300dp"
android:minWidth="300dp">
<EditText
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/Firstname"
android:background="#drawable/editstyle"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="25dp"
android:hint="Username"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000" />
<EditText
android:layout_below="#+id/Firstname"
android:inputType="textEmailAddress"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/textEmail"
android:background="#drawable/editstyle"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Email/Phone Number"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000" />
<EditText
android:layout_below="#+id/textEmail"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/password"
android:background="#drawable/editstyle"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Password"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000" />
<Button
android:layout_below="#+id/password"
android:text="Sign Up"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/btnDialogEmail"
android:textColor="#FFFFFF"
android:background="#drawable/butto1"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:shadowColor="#00ffffff"
android:shadowRadius="5"
android:drawableRight="#drawable/goodmess" />
</RelativeLayout>
-->
and the dialog_signup.cs
using Android.Views;
using Android.Widget;
namespace GameLandPlus
{
class dialog_signup:DialogFragment
{
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState)
{
base.OnCreateView(inflater, container, saveInstanceState);
var view = inflater.Inflate(Resource.Layout.dialogSignup, container, false);
return view;
}
public override void OnActivityCreated(Bundle savedInstanceState)
{
Dialog.Window.RequestFeature(WindowFeatures.NoTitle);//set title
base.OnActivityCreated(savedInstanceState);
Dialog.Window.Attributes.WindowAnimations = Resource.Style.dialog_animation;
}
}
}
-->
i do not include the slideup/slideright/butto1 because is the drawable file.
Please can u check on it.
I already change emulator so far. but i dont know where is the problem.
Any suggestion?

Resources