<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.example.customviews">
<com.example.customviews.MyEditText
android:id="@+id/my_input"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:inputType="My text"
/>
</LinearLayout>
MyEditText text = (MyEditText) findViewById(R.id.my_input)
public class FontChangeCrawler {
private Typeface typeface;
public FontChangeCrawler(Typeface typeface) {
this.typeface = typeface;
}
public FontChangeCrawler(AssetManager assets, String assetsFontFileName) {
typeface = Typeface.createFromAsset(assets, assetsFontFileName);
}
public void replaceFonts(ViewGroup viewTree) {
View child;
for (int i = 0; i < viewTree.getChildCount(); ++i) {
child = viewTree.getChildAt(i);
if (child instanceof ViewGroup) {
replaceFonts((ViewGroup)child);
}
else if (child instanceof TextView) {
((TextView) child).setTypeface(typeface);
}
}
}
}
public class MainActivity extends AppCompatActivity {
@Override
public void setContentView(View view) {
super.setContentView(view);
FontChangeCrawler fontChanger = new FontChangeCrawler(getAssets(), "fonts/myfont.otf");
fontChanger.replaceFonts((ViewGroup)this.findViewById(android.R.id.content));
}
}
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator elevationDownAnimator = ObjectAnimator
.ofFloat(mRadioView1, "elevation", 5, 0)
.setDuration(3000);
ObjectAnimator elevationUpAnimator = ObjectAnimator
.ofFloat(mRadioView2, "elevation", 0, 5)
.setDuration(3000);
animatorSet
.play(elevationDownAnimator)
.with(elevationUpAnimator)
animatorSet.start();
public class WebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url)
{
view.loadUrl("javascript:document.forms[0].q.value='qwerty'");
}
}
WebView webview = new WebView();
webview.setWebViewClient(new WebClient());
webView.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("toster.ru");
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
class Department {
private String number;
private String name;
private List<Integer> products;
public Department(String number, String name) {
this.number = number;
this.name = name;
this.products = new ArrayList<>();
}
public void setProducts(List<Integer> products) {
this.products = products;
}
public String toString() {
return String.format("Name: %s\nNumber: %s\nProducts: %s\n", name, number, products);
}
}
public class SAXHandler extends DefaultHandler {
private List<Department> departments;
private List<Integer> products;
private Department currentDepartment;
public SAXHandler() {
this.departments = new ArrayList<>();
}
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if(qName.equals("department")) {
String name = attributes.getValue("name");
String number = attributes.getValue("number");
products = new ArrayList<>();
currentDepartment = new Department(name, number);
}
if(qName.equals("product")) {
String id = attributes.getValue("id");
products.add(Integer.valueOf(id));
}
}
public void endElement(String uri, String localName, String qName) throws SAXException {
if(qName.equals("department")) {
currentDepartment.setProducts(products);
departments.add(currentDepartment);
}
}
public List<Department> getResult() {
return departments;
}
public static void main(final String args[]) {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
SAXHandler handler = new SAXHandler();
saxParser.parse("test.xml", handler);
handler.getResult().stream().forEach(System.out::println);
}
catch(SAXException ex) {}
catch(ParserConfigurationException ex) {}
catch(IOException ex) {}
}
}
Map<String, String> attrs = new HashMap<>();
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
String name = attributes.getValue("name");
String value = attributes.getValue("size");
attrs.put(name, value);
}