AppCompat 23.2.0
.VectorDrawableCompat
.Gradle
вашего проекта,exception
, как и у вас.Gradle wrapper >= 2.0
):android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Gradle wrapper == 1.5
; скорее всего он вам и подойдёт)android {
defaultConfig {
// Stops the Gradle plugin’s automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_search"/>
app:srcCompat="@drawable/ic_search"
R.java
былtoolbar
, в котором делаем, что нужно:appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (isCollapsed(verticalOffset)) {
//set status bar color your color
} else {
// set status bar color transparent
}
}
});
private boolean isCollapsed(int offset) {
return offset == 0 || offset <= toolbar.getHeight();
}
String correctUserName = "Здесь ваше имя пользователя латиницей";
System.setProperty("user.name",correctUserName);
public static void main (String[] arg) {
setupUserName();
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new Touch(), config);
}
private static void setupUserName() {
String correctUserName = "Здесь ваше имя пользователя латиницей";
System.setProperty("user.name",correctUserName);
}
.3ds
в расширение.obj
..obj
- легко ищется поисковиком..obj
конвертируют в более дружественный для runtime и меньший по весу формат .g3db
.String pathToTor = "D:\\Tor\\Tor Browser\\Browser\\firefox.exe"; //путь к браузеру
String link = "http:\\stackoverflow.com\\"; //ссылка
String request = String.format("%s %s", pathToTor, link);
Runtime runtime = Runtime.getRuntime();
runtime.exec(request);
Класс реализации:
public class BrowserOpener {
private String os;
private Runtime runtime;
public BrowserOpener() {
os = System.getProperty("os.name").toLowerCase();
runtime = Runtime.getRuntime();
}
public void openLinkInBrowser(String url) {
try {
if (isWindows()) {
runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (isMac()) {
runtime.exec("open " + url);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean isWindows() {
return os.contains("win");
}
private boolean isMac() {
return os.contains("mac");
}
}
Класс c методом Main:
import java.io.IOException;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws IOException, URISyntaxException {
BrowserOpener opener = new BrowserOpener();
opener.openLinkInBrowser("http://stackoverflow.com/");
}
}
public void MyButtonClick(View view) {
int count = gridView.getChildCount();
for (int i = 0; i < count; i++) {
View cell = gridView.getChildAt(i);
TextView cellText = (TextView) cell.findViewById(R.id.textpart);
cellText.setTextColor(Color.parseColor("#FF0033"));
}
}
public class MainActivity extends Activity {
private GridView gridView;
private ImageTextAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new ImageTextAdapter(this);
gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(gridViewOnItemClickListener);
}
private GridView.OnItemClickListener gridViewOnItemClickListener = new GridView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // пожалуйста, не комментируйте код так:
// Sending image id to FullScreenActivity
//Intent i = new Intent(getApplicationContext(),
// FullImageActivity.class);
// passing array index
//i.putExtra("id", position);
//startActivity(i);
}
};
public void MyButtonClick(View view) { // нарушение Code Convention в имени метода
int count = gridView.getChildCount();
for (int i = 0; i < count; i++) {
View cell = gridView.getChildAt(i);
TextView cellText = (TextView) cell.findViewById(R.id.textpart);
cellText.setTextColor(Color.parseColor("#FF0033"));
}
}
}
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageTextAdapter(this));
gridview.setOnItemClickListener(gridviewOnItemClickListener);
}
private GridView.OnItemClickListener gridviewOnItemClickListener = new GridView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
// TODO Auto-generated method stub
// Sending image id to FullScreenActivity
//Intent i = new Intent(getApplicationContext(),
// FullImageActivity.class);
// passing array index
//i.putExtra("id", position);
//startActivity(i);
}
};
public void MyButtonClick(View view)
{
View cell = findViewById(R.layout.cellgrid);
TextView cellText = cell.findViewById(R.id.textpart);
cellText.setTextColor(Color.parseColor("#000000"));
}
}
но можно увеличить до Java 8 с помощью сторонних библиотек
import javafx.util.Pair;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
Pair<Integer, Integer> position = new Pair<Integer, Integer>(-1, 3);
Map<Pair<Integer, Integer>, Integer> myMatrix = buildMatrix();
myMatrix.put(position, 9);
outputValue(myMatrix, position);
}
private static Map<Pair<Integer, Integer>, Integer> buildMatrix() {
return new HashMap<>();
}
private static void outputValue(Map<Pair<Integer, Integer>, Integer> map, Pair<Integer, Integer> key) {
System.out.println(map.get(key));
}
}
private URI mImageUri;
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo;
try
{
// место где хранятся фото
photo = this.createTemporaryFile("picture", ".jpg");
photo.delete();
}
catch(Exception e)
{
Log.v(TAG, "Не получилось создать фото!");
Toast.makeText(activity, "Пожалуйста, проверьте Sd - карту", 10000);
return false;
}
mImageUri = Uri.fromFile(photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
//вызываем Intent камеры
activity.startActivityForResult(this, intent, MenuShootImage);
private File createTemporaryFile(String part, String ext) throws Exception
{
File tempDir= Environment.getExternalStorageDirectory();
tempDir=new File(tempDir.getAbsolutePath()+"/.temp/");
if(!tempDir.exists())
{
tempDir.mkdir();
}
return File.createTempFile(part, ext, tempDir);
}
imageUri
:public void grabImage(ImageView imageView)
{
this.getContentResolver().notifyChange(mImageUri, null);
ContentResolver cr = this.getContentResolver();
Bitmap bitmap;
try
{
bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, mImageUri);
imageView.setImageBitmap(bitmap);
}
catch (Exception e)
{
Toast.makeText(this, "Ошибка загрузки", Toast.LENGTH_SHORT).show();
Log.d(TAG, "Ошибка загрузки", e);
}
}
//вызов камеры после выполнения
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if(requestCode==MenuShootImage && resultCode==RESULT_OK)
{
ImageView imageView;
//делаем, что нужно с картинкой
this.grabImage(imageView);
}
super.onActivityResult(requestCode, resultCode, intent);
}
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application>
...
</application>
/ Storage Permissions
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
/**
* Checks if the app has permission to write to device storage
*
* If the app does not has permission then the user will be prompted to grant permissions
*
* @param activity
*/
public static void verifyStoragePermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
ActivityCompat.requestPermissions(
activity,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}
}
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.M){
} else{
}